This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 408
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(node): add task to run a subset of tests on node
`npm run test-node` or `gulp test/node` will now run tests on node.js. These are also run on TravisCI. Clean up gulp build.
- Loading branch information
Showing
10 changed files
with
160 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,4 +24,4 @@ before_script: | |
|
||
script: | ||
- node_modules/.bin/karma start karma-sauce.conf.js | ||
|
||
- node_modules/.bin/gulp test/node |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
describe('Zone', function () { | ||
var rootZone = Zone.current; | ||
|
||
describe('hooks', function () { | ||
it('should allow you to override alert/prompt/confirm', function () { | ||
var alertSpy = jasmine.createSpy('alert'); | ||
var promptSpy = jasmine.createSpy('prompt'); | ||
var confirmSpy = jasmine.createSpy('confirm'); | ||
var spies = { | ||
'alert': alertSpy, | ||
'prompt': promptSpy, | ||
'confirm': confirmSpy | ||
}; | ||
var myZone = Zone.current.fork({ | ||
name: 'spy', | ||
onInvoke: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
callback: Function, applyThis: any, applyArgs: any[], source: string): any => | ||
{ | ||
if (source) { | ||
spies[source].apply(null, applyArgs); | ||
} else { | ||
return parentZoneDelegate.invoke(targetZone, callback, applyThis, applyArgs, source); | ||
} | ||
} | ||
}); | ||
|
||
myZone.run(function () { | ||
alert('alertMsg'); | ||
prompt('promptMsg', 'default'); | ||
confirm('confirmMsg'); | ||
}); | ||
|
||
expect(alertSpy).toHaveBeenCalledWith('alertMsg'); | ||
expect(promptSpy).toHaveBeenCalledWith('promptMsg', 'default'); | ||
expect(confirmSpy).toHaveBeenCalledWith('confirmMsg'); | ||
}); | ||
|
||
describe('eventListener hooks', function () { | ||
var button; | ||
var clickEvent; | ||
|
||
beforeEach(function () { | ||
button = document.createElement('button'); | ||
clickEvent = document.createEvent('Event'); | ||
clickEvent.initEvent('click', true, true); | ||
document.body.appendChild(button); | ||
}); | ||
|
||
afterEach(function () { | ||
document.body.removeChild(button); | ||
}); | ||
|
||
it('should support addEventListener', function () { | ||
var hookSpy = jasmine.createSpy('hook'); | ||
var eventListenerSpy = jasmine.createSpy('eventListener'); | ||
var zone = rootZone.fork({ | ||
name: 'spy', | ||
onScheduleTask: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
task: Task): any => { | ||
hookSpy(); | ||
return parentZoneDelegate.scheduleTask(targetZone, task); | ||
} | ||
}); | ||
|
||
zone.run(function() { | ||
button.addEventListener('click', eventListenerSpy); | ||
}); | ||
|
||
button.dispatchEvent(clickEvent); | ||
|
||
expect(hookSpy).toHaveBeenCalled(); | ||
expect(eventListenerSpy).toHaveBeenCalled(); | ||
}); | ||
|
||
it('should support removeEventListener', function () { | ||
var hookSpy = jasmine.createSpy('hook'); | ||
var eventListenerSpy = jasmine.createSpy('eventListener'); | ||
var zone = rootZone.fork({ | ||
name: 'spy', | ||
onCancelTask: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
task: Task): any => { | ||
hookSpy(); | ||
return parentZoneDelegate.cancelTask(targetZone, task); | ||
} | ||
}); | ||
|
||
zone.run(function() { | ||
button.addEventListener('click', eventListenerSpy); | ||
button.removeEventListener('click', eventListenerSpy); | ||
}); | ||
|
||
button.dispatchEvent(clickEvent); | ||
|
||
expect(hookSpy).toHaveBeenCalled(); | ||
expect(eventListenerSpy).not.toHaveBeenCalled(); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import './common/microtasks.spec'; | ||
import './common/zone.spec'; | ||
import './common/util.spec'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Setup tests for Zone without microtask support | ||
import '../lib/zone'; | ||
import '../lib/node/node'; | ||
import '../lib/zone-spec/long-stack-trace'; | ||
|
||
// Setup test environment | ||
import './test-env-setup'; | ||
|
||
// List all tests here: | ||
import './common_tests'; | ||
import './zone-spec/long-stack-trace-zone.spec'; |