From 791ce1a9c3ef5588bc3acd02d1a0ba5af314e5e0 Mon Sep 17 00:00:00 2001 From: "JiaLi.Passion" Date: Tue, 8 May 2018 00:03:35 +0900 Subject: [PATCH] refactor(test): refactor folder of test/build/ci --- .travis.yml | 17 +- README.md | 8 +- MODULE.md => doc/design/MODULE.md | 0 .../design/NON-STANDARD-APIS.md | 0 .../design/STANDARD-APIS.md | 0 doc/{ => lifecycle/png}/error.png | Bin doc/{ => lifecycle/png}/eventtask.png | Bin doc/{ => lifecycle/png}/microtask.png | Bin .../png}/non-periodical-macrotask.png | Bin doc/{ => lifecycle/png}/override-task.png | Bin .../png}/periodical-macrotask.png | Bin doc/{ => lifecycle/png}/reschedule-task.png | Bin doc/{ => lifecycle/puml}/error.puml | 0 doc/{ => lifecycle/puml}/eventtask.puml | 0 doc/{ => lifecycle/puml}/microtask.puml | 0 .../puml}/non-periodical-macrotask.puml | 0 doc/{ => lifecycle/puml}/override-task.puml | 0 .../puml}/periodical-macrotask.puml | 0 doc/{ => lifecycle/puml}/reschedule-task.puml | 0 doc/{ => lifecycle}/task.md | 0 gulpfile.js | 13 +- karma-dist-sauce-jasmine3.conf.js | 12 - lib/jasmine/jasmine-patch.ts | 30 +- lib/jasmine/mocha-bridge/mocha.bdd.ts | 17 + lib/jasmine/mocha-bridge/mocha.ts | 3 +- lib/mocha/jasmine-bridge/jasmine.bdd.ts | 2 +- lib/mocha/jasmine-bridge/jasmine.ts | 1 + lib/mocha/mocha-patch.ts | 2 +- package.json | 26 +- promise.finally.spec.js | 345 --------------- scripts/closure/closure_flagfile | 2 +- .../size/check-file-size.js | 0 .../size/file-size-limit.json | 0 test/browser-zone-setup.ts | 22 - test/browser_entry_point.ts | 26 -- test/common_tests.ts | 26 -- test/env/browser/browser-zone-setup.ts | 22 + test/env/browser/browser_entry_point.ts | 25 ++ test/{ => env/browser}/main.ts | 10 +- test/env/common/common_tests.ts | 28 ++ test/{ => env/config}/saucelabs.js | 0 .../test-env-setup-jasmine-no-patch-clock.ts | 0 .../config}/test-env-setup-jasmine.ts | 0 test/{ => env/config}/test-env-setup-mocha.ts | 0 test/env/node/node_bluebird_entry_point.ts | 32 ++ test/{ => env/node}/node_entry_point.ts | 22 +- test/env/node/node_tests.ts | 15 + .../{ => env/polyfills}/test_fake_polyfill.ts | 0 test/{ => env/polyfills}/wtf_mock.ts | 0 test/{ => env/websocket}/ws-client.js | 0 test/{ => env/websocket}/ws-server.js | 0 .../websocket}/ws-webworker-context.ts | 6 +- .../websocket}/zone_worker_entry_point.ts | 2 +- .../ci/build/karma-build-sauce-mocha.conf.js | 6 +- .../karma-build-sauce-selenium3-mocha.conf.js | 6 +- .../ci/dist/karma-dist-sauce-jasmine.conf.js | 6 +- .../ci/dist/karma-dist-sauce-jasmine3.conf.js | 16 + ...karma-dist-sauce-selenium3-jasmine.conf.js | 6 +- .../karma/ci/sauce-selenium3.conf.js | 29 +- sauce.conf.js => test/karma/ci/sauce.conf.js | 2 +- .../karma-build-jasmine-phantomjs.conf.js | 2 +- .../common/build/karma-build-jasmine.conf.js | 3 +- .../karma-build-mocha-jasmine-bridge.conf.js | 10 +- .../common/build/karma-build-mocha.conf.js | 0 .../karma/common/build/karma-build.conf.js | 10 +- .../common/dist/karma-dist-jasmine.conf.js | 2 +- .../common/dist/karma-dist-mocha.conf.js | 0 .../karma/common/dist/karma-dist.conf.js | 9 +- .../karma/common/karma-base.conf.js | 32 +- test/node_bluebird_entry_point.ts | 32 -- test/node_tests.ts | 15 - test/rxjs/rxjs.fromEvent.spec.ts | 121 ------ test/{ => spec}/browser/FileReader.spec.ts | 0 test/{ => spec}/browser/HTMLImports.spec.ts | 0 test/{ => spec}/browser/MediaQuery.spec.ts | 4 +- .../browser/MutationObserver.spec.ts | 0 test/{ => spec}/browser/Notification.spec.ts | 4 +- test/{ => spec}/browser/WebSocket.spec.ts | 4 +- test/{ => spec}/browser/Worker.spec.ts | 2 +- .../{ => spec}/browser/XMLHttpRequest.spec.ts | 0 test/{ => spec}/browser/browser.spec.ts | 8 +- .../browser/define-property.spec.ts | 0 test/{ => spec}/browser/element.spec.ts | 0 .../browser/geolocation.spec.manual.ts | 0 .../browser/registerElement.spec.ts | 0 .../browser/requestAnimationFrame.spec.ts | 0 test/{ => spec}/closure/zone.closure.ts | 0 test/{ => spec}/common/Error.spec.ts | 0 test/{ => spec}/common/Promise.spec.ts | 78 ++-- test/{ => spec}/common/microtasks.spec.ts | 0 test/{ => spec}/common/setInterval.spec.ts | 4 +- test/{ => spec}/common/setTimeout.spec.ts | 3 +- test/{ => spec}/common/task.spec.ts | 0 test/{ => spec}/common/toString.spec.ts | 5 +- test/{ => spec}/common/util.spec.ts | 3 +- test/{ => spec}/common/zone.spec.ts | 20 +- test/{ => spec}/extra/bluebird.spec.ts | 97 +++-- test/{ => spec}/extra/cordova.spec.ts | 0 test/{ => spec/jasmine}/jasmine-patch.spec.ts | 16 +- test/{ => spec}/mocha/jasmine-bridge.spec.ts | 2 +- test/{ => spec}/mocha/mocha-browser-karma.ts | 0 .../mocha/mocha-browser-test-entry-point.ts | 0 .../mocha/mocha-node-test-entry-point.ts | 6 +- test/{ => spec}/mocha/mocha-patch.spec.ts | 20 +- test/{ => spec}/node/Error.spec.ts | 0 test/{ => spec}/node/console.spec.ts | 0 test/{ => spec}/node/crypto.spec.ts | 0 test/{ => spec}/node/events.spec.ts | 0 test/{ => spec}/node/fs.spec.ts | 0 test/{ => spec}/node/http.spec.ts | 0 test/{ => spec}/node/process.spec.ts | 24 +- test/{ => spec}/patch/IndexedDB.spec.js | 0 .../spec/promise/promise-adapter.js | 4 +- test/spec/promise/promise.finally.spec.js | 392 ++++++++++++++++++ .../rxjs/rxjs.Observable.audit.spec.ts | 0 .../rxjs/rxjs.Observable.buffer.spec.ts | 0 .../rxjs/rxjs.Observable.catch.spec.ts | 0 .../rxjs/rxjs.Observable.collection.spec.ts | 0 .../rxjs/rxjs.Observable.combine.spec.ts | 0 .../rxjs/rxjs.Observable.concat.spec.ts | 0 .../rxjs/rxjs.Observable.count.spec.ts | 0 .../rxjs/rxjs.Observable.debounce.spec.ts | 0 .../rxjs/rxjs.Observable.default.spec.ts | 0 .../rxjs/rxjs.Observable.delay.spec.ts | 0 .../rxjs/rxjs.Observable.distinct.spec.ts | 0 .../rxjs/rxjs.Observable.do.spec.ts | 0 .../rxjs/rxjs.Observable.map.spec.ts | 0 .../rxjs/rxjs.Observable.merge.spec.ts | 0 .../rxjs/rxjs.Observable.multicast.spec.ts | 0 .../rxjs/rxjs.Observable.notification.spec.ts | 0 .../rxjs/rxjs.Observable.race.spec.ts | 0 .../rxjs/rxjs.Observable.sample.spec.ts | 0 .../rxjs/rxjs.Observable.take.spec.ts | 0 .../rxjs/rxjs.Observable.timeout.spec.ts | 0 .../rxjs/rxjs.Observable.window.spec.ts | 0 test/{ => spec}/rxjs/rxjs.asap.spec.ts | 0 .../{ => spec}/rxjs/rxjs.bindCallback.spec.ts | 0 .../rxjs/rxjs.bindNodeCallback.spec.ts | 0 .../rxjs/rxjs.combineLatest.spec.ts | 0 test/{ => spec}/rxjs/rxjs.common.spec.ts | 0 test/{ => spec}/rxjs/rxjs.concat.spec.ts | 0 test/{ => spec}/rxjs/rxjs.defer.spec.ts | 0 test/{ => spec}/rxjs/rxjs.empty.spec.ts | 0 test/{ => spec}/rxjs/rxjs.forkjoin.spec.ts | 0 test/{ => spec}/rxjs/rxjs.from.spec.ts | 0 test/spec/rxjs/rxjs.fromEvent.spec.ts | 105 +++++ test/{ => spec}/rxjs/rxjs.fromPromise.spec.ts | 0 test/{ => spec}/rxjs/rxjs.interval.spec.ts | 0 test/{ => spec}/rxjs/rxjs.merge.spec.ts | 0 test/{ => spec}/rxjs/rxjs.never.spec.ts | 0 test/{ => spec}/rxjs/rxjs.of.spec.ts | 0 test/{ => spec}/rxjs/rxjs.range.spec.ts | 0 test/{ => spec}/rxjs/rxjs.spec.ts | 2 +- test/{ => spec}/rxjs/rxjs.throw.spec.ts | 0 test/{ => spec}/rxjs/rxjs.timer.spec.ts | 0 test/{ => spec}/rxjs/rxjs.zip.spec.ts | 0 test/{ => spec}/test-util.ts | 0 .../spec/webdriver/simple-server.js | 6 +- test/{ => spec}/webdriver/test.html | 2 +- test/{ => spec}/webdriver/test.js | 0 test/{ => spec}/webdriver/test.sauce.js | 10 +- test/{ => spec}/zone-spec/async-test.spec.ts | 0 .../zone-spec/fake-async-test.spec.ts | 13 +- .../zone-spec/long-stack-trace-zone.spec.ts | 15 +- test/{ => spec}/zone-spec/proxy.spec.ts | 0 test/{ => spec}/zone-spec/sync-test.spec.ts | 0 .../zone-spec/task-tracking.spec.ts | 0 167 files changed, 969 insertions(+), 901 deletions(-) rename MODULE.md => doc/design/MODULE.md (100%) rename NON-STANDARD-APIS.md => doc/design/NON-STANDARD-APIS.md (100%) rename STANDARD-APIS.md => doc/design/STANDARD-APIS.md (100%) rename doc/{ => lifecycle/png}/error.png (100%) rename doc/{ => lifecycle/png}/eventtask.png (100%) rename doc/{ => lifecycle/png}/microtask.png (100%) rename doc/{ => lifecycle/png}/non-periodical-macrotask.png (100%) rename doc/{ => lifecycle/png}/override-task.png (100%) rename doc/{ => lifecycle/png}/periodical-macrotask.png (100%) rename doc/{ => lifecycle/png}/reschedule-task.png (100%) rename doc/{ => lifecycle/puml}/error.puml (100%) rename doc/{ => lifecycle/puml}/eventtask.puml (100%) rename doc/{ => lifecycle/puml}/microtask.puml (100%) rename doc/{ => lifecycle/puml}/non-periodical-macrotask.puml (100%) rename doc/{ => lifecycle/puml}/override-task.puml (100%) rename doc/{ => lifecycle/puml}/periodical-macrotask.puml (100%) rename doc/{ => lifecycle/puml}/reschedule-task.puml (100%) rename doc/{ => lifecycle}/task.md (100%) delete mode 100644 karma-dist-sauce-jasmine3.conf.js delete mode 100644 promise.finally.spec.js rename check-file-size.js => scripts/size/check-file-size.js (100%) rename file-size-limit.json => scripts/size/file-size-limit.json (100%) delete mode 100644 test/browser-zone-setup.ts delete mode 100644 test/browser_entry_point.ts delete mode 100644 test/common_tests.ts create mode 100644 test/env/browser/browser-zone-setup.ts create mode 100644 test/env/browser/browser_entry_point.ts rename test/{ => env/browser}/main.ts (78%) create mode 100644 test/env/common/common_tests.ts rename test/{ => env/config}/saucelabs.js (100%) rename test/{ => env/config}/test-env-setup-jasmine-no-patch-clock.ts (100%) rename test/{ => env/config}/test-env-setup-jasmine.ts (100%) rename test/{ => env/config}/test-env-setup-mocha.ts (100%) create mode 100644 test/env/node/node_bluebird_entry_point.ts rename test/{ => env/node}/node_entry_point.ts (56%) create mode 100644 test/env/node/node_tests.ts rename test/{ => env/polyfills}/test_fake_polyfill.ts (100%) rename test/{ => env/polyfills}/wtf_mock.ts (100%) rename test/{ => env/websocket}/ws-client.js (100%) rename test/{ => env/websocket}/ws-server.js (100%) rename test/{ => env/websocket}/ws-webworker-context.ts (58%) rename test/{ => env/websocket}/zone_worker_entry_point.ts (92%) rename karma-build-sauce-mocha.conf.js => test/karma/ci/build/karma-build-sauce-mocha.conf.js (60%) rename karma-build-sauce-selenium3-mocha.conf.js => test/karma/ci/build/karma-build-sauce-selenium3-mocha.conf.js (56%) rename karma-dist-sauce-jasmine.conf.js => test/karma/ci/dist/karma-dist-sauce-jasmine.conf.js (57%) create mode 100644 test/karma/ci/dist/karma-dist-sauce-jasmine3.conf.js rename karma-dist-sauce-selenium3-jasmine.conf.js => test/karma/ci/dist/karma-dist-sauce-selenium3-jasmine.conf.js (58%) rename sauce-selenium3.conf.js => test/karma/ci/sauce-selenium3.conf.js (57%) rename sauce.conf.js => test/karma/ci/sauce.conf.js (98%) rename karma-build-jasmine-phantomjs.conf.js => test/karma/common/build/karma-build-jasmine-phantomjs.conf.js (86%) rename karma-build-jasmine.conf.js => test/karma/common/build/karma-build-jasmine.conf.js (77%) rename karma-build-mocha-jasmine-bridge.conf.js => test/karma/common/build/karma-build-mocha-jasmine-bridge.conf.js (60%) rename karma-build-mocha.conf.js => test/karma/common/build/karma-build-mocha.conf.js (100%) rename karma-build.conf.js => test/karma/common/build/karma-build.conf.js (57%) rename karma-dist-jasmine.conf.js => test/karma/common/dist/karma-dist-jasmine.conf.js (78%) rename karma-dist-mocha.conf.js => test/karma/common/dist/karma-dist-mocha.conf.js (100%) rename karma-dist.conf.js => test/karma/common/dist/karma-dist.conf.js (68%) rename karma-base.conf.js => test/karma/common/karma-base.conf.js (68%) delete mode 100644 test/node_bluebird_entry_point.ts delete mode 100644 test/node_tests.ts delete mode 100644 test/rxjs/rxjs.fromEvent.spec.ts rename test/{ => spec}/browser/FileReader.spec.ts (100%) rename test/{ => spec}/browser/HTMLImports.spec.ts (100%) rename test/{ => spec}/browser/MediaQuery.spec.ts (89%) rename test/{ => spec}/browser/MutationObserver.spec.ts (100%) rename test/{ => spec}/browser/Notification.spec.ts (89%) rename test/{ => spec}/browser/WebSocket.spec.ts (95%) rename test/{ => spec}/browser/Worker.spec.ts (95%) rename test/{ => spec}/browser/XMLHttpRequest.spec.ts (100%) rename test/{ => spec}/browser/browser.spec.ts (99%) rename test/{ => spec}/browser/define-property.spec.ts (100%) rename test/{ => spec}/browser/element.spec.ts (100%) rename test/{ => spec}/browser/geolocation.spec.manual.ts (100%) rename test/{ => spec}/browser/registerElement.spec.ts (100%) rename test/{ => spec}/browser/requestAnimationFrame.spec.ts (100%) rename test/{ => spec}/closure/zone.closure.ts (100%) rename test/{ => spec}/common/Error.spec.ts (100%) rename test/{ => spec}/common/Promise.spec.ts (90%) rename test/{ => spec}/common/microtasks.spec.ts (100%) rename test/{ => spec}/common/setInterval.spec.ts (98%) rename test/{ => spec}/common/setTimeout.spec.ts (98%) rename test/{ => spec}/common/task.spec.ts (100%) rename test/{ => spec}/common/toString.spec.ts (94%) rename test/{ => spec}/common/util.spec.ts (99%) rename test/{ => spec}/common/zone.spec.ts (97%) rename test/{ => spec}/extra/bluebird.spec.ts (91%) rename test/{ => spec}/extra/cordova.spec.ts (100%) rename test/{ => spec/jasmine}/jasmine-patch.spec.ts (80%) rename test/{ => spec}/mocha/jasmine-bridge.spec.ts (99%) rename test/{ => spec}/mocha/mocha-browser-karma.ts (100%) rename test/{ => spec}/mocha/mocha-browser-test-entry-point.ts (100%) rename test/{ => spec}/mocha/mocha-node-test-entry-point.ts (63%) rename test/{ => spec}/mocha/mocha-patch.spec.ts (92%) rename test/{ => spec}/node/Error.spec.ts (100%) rename test/{ => spec}/node/console.spec.ts (100%) rename test/{ => spec}/node/crypto.spec.ts (100%) rename test/{ => spec}/node/events.spec.ts (100%) rename test/{ => spec}/node/fs.spec.ts (100%) rename test/{ => spec}/node/http.spec.ts (100%) rename test/{ => spec}/node/process.spec.ts (83%) rename test/{ => spec}/patch/IndexedDB.spec.js (100%) rename promise-adapter.js => test/spec/promise/promise-adapter.js (83%) create mode 100644 test/spec/promise/promise.finally.spec.js rename test/{ => spec}/rxjs/rxjs.Observable.audit.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.Observable.buffer.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.Observable.catch.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.Observable.collection.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.Observable.combine.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.Observable.concat.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.Observable.count.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.Observable.debounce.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.Observable.default.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.Observable.delay.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.Observable.distinct.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.Observable.do.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.Observable.map.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.Observable.merge.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.Observable.multicast.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.Observable.notification.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.Observable.race.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.Observable.sample.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.Observable.take.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.Observable.timeout.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.Observable.window.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.asap.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.bindCallback.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.bindNodeCallback.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.combineLatest.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.common.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.concat.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.defer.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.empty.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.forkjoin.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.from.spec.ts (100%) create mode 100644 test/spec/rxjs/rxjs.fromEvent.spec.ts rename test/{ => spec}/rxjs/rxjs.fromPromise.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.interval.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.merge.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.never.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.of.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.range.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.spec.ts (98%) rename test/{ => spec}/rxjs/rxjs.throw.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.timer.spec.ts (100%) rename test/{ => spec}/rxjs/rxjs.zip.spec.ts (100%) rename test/{ => spec}/test-util.ts (100%) rename simple-server.js => test/spec/webdriver/simple-server.js (97%) rename test/{ => spec}/webdriver/test.html (65%) rename test/{ => spec}/webdriver/test.js (100%) rename test/{ => spec}/webdriver/test.sauce.js (95%) rename test/{ => spec}/zone-spec/async-test.spec.ts (100%) rename test/{ => spec}/zone-spec/fake-async-test.spec.ts (99%) rename test/{ => spec}/zone-spec/long-stack-trace-zone.spec.ts (93%) rename test/{ => spec}/zone-spec/proxy.spec.ts (100%) rename test/{ => spec}/zone-spec/sync-test.spec.ts (100%) rename test/{ => spec}/zone-spec/task-tracking.spec.ts (100%) diff --git a/.travis.yml b/.travis.yml index 7add517ea..28ef8cf91 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,20 +35,19 @@ script: - node_modules/.bin/gulp promisetest - yarn promisefinallytest - yarn test:phantomjs-single - - node_modules/.bin/karma start karma-dist-sauce-jasmine.conf.js --single-run - - node_modules/.bin/karma start karma-build-sauce-mocha.conf.js --single-run - - node_modules/.bin/karma start karma-dist-sauce-selenium3-jasmine.conf.js --single-run - - node_modules/.bin/karma start karma-build-sauce-selenium3-mocha.conf.js --single-run + - node_modules/.bin/karma start ./test/karma/ci/dist/karma-dist-sauce-jasmine.conf.js --single-run + - node_modules/.bin/karma start ./test/karma/ci/build/karma-build-sauce-mocha.conf.js --single-run + - node_modules/.bin/karma start ./test/karma/ci/dist/karma-dist-sauce-selenium3-jasmine.conf.js --single-run + - node_modules/.bin/karma start ./test/karma/ci/build/karma-build-sauce-selenium3-mocha.conf.js --single-run - node_modules/.bin/gulp test/node - node_modules/.bin/gulp test/node -no-patch-clock - node_modules/.bin/gulp test/bluebird - - node simple-server.js 2>&1> server.log& - - node ./test/webdriver/test.sauce.js + - node ./test/spec/webdriver/simple-server.js 2>&1> server.log& + - node ./test/spec/webdriver/test.sauce.js - yarn add jasmine@3.0.0 jasmine-core@3.0.0 mocha@5.0.1 - yarn test:phantomjs-single - yarn test-mocha-jasmine-bridge-node - - yarn test-mocha-jasmine-bridge-browser - - node_modules/.bin/karma start karma-dist-sauce-jasmine3.conf.js --single-run - - node_modules/.bin/karma start karma-build-sauce-selenium3-mocha.conf.js --single-run + - node_modules/.bin/karma start ./test/karma/ci/dist/karma-dist-sauce-jasmine3.conf.js --single-run + - node_modules/.bin/karma start ./test/karma/ci/build/karma-build-sauce-selenium3-mocha.conf.js --single-run - node_modules/.bin/gulp test/node - node_modules/.bin/gulp test/node -no-patch-clock diff --git a/README.md b/README.md index a9f854ce8..943b8a7fd 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Implements _Zones_ for JavaScript, inspired by [Dart](https://www.dartlang.org/articles/zones/). > If you're using zone.js via unpkg (i.e. using `https://unpkg.com/zone.js`) -> and you're using any of the following libraries, make sure you import them first +> and you're using any of the following libraries, make sure you import them first > * 'newrelic' as it patches global.Promise before zone.js does > * 'async-listener' as it patches global.setTimeout, global.setInterval before zone.js does @@ -36,19 +36,19 @@ See this video from ng-conf 2014 for a detailed explanation: ## Standard API support zone.js patched most standard web APIs (such as DOM events, `XMLHttpRequest`, ...) and nodejs APIs -(`EventEmitter`, `fs`, ...), for more details, please see [STANDARD-APIS.md](STANDARD-APIS.md). +(`EventEmitter`, `fs`, ...), for more details, please see [STANDARD-APIS.md](./doc/design/STANDARD-APIS.md). ## Nonstandard API support We are adding support to some nonstandard APIs, such as MediaQuery and -Notification. Please see [NON-STANDARD-APIS.md](NON-STANDARD-APIS.md) for more details. +Notification. Please see [NON-STANDARD-APIS.md](./doc/design/NON-STANDARD-APIS.md) for more details. ## Modules zone.js patches the async APIs described above, but those patches will have some overhead. Starting from zone.js v0.8.9, you can choose which web API module you want to patch. For more details, please -see [MODULE.md](MODULE.md). +see [MODULE.md](./doc/design/MODULE.md). ## Promise A+ test passed [![Promises/A+ 1.1 compliant](https://promisesaplus.com/assets/logo-small.png)](https://promisesaplus.com/) diff --git a/MODULE.md b/doc/design/MODULE.md similarity index 100% rename from MODULE.md rename to doc/design/MODULE.md diff --git a/NON-STANDARD-APIS.md b/doc/design/NON-STANDARD-APIS.md similarity index 100% rename from NON-STANDARD-APIS.md rename to doc/design/NON-STANDARD-APIS.md diff --git a/STANDARD-APIS.md b/doc/design/STANDARD-APIS.md similarity index 100% rename from STANDARD-APIS.md rename to doc/design/STANDARD-APIS.md diff --git a/doc/error.png b/doc/lifecycle/png/error.png similarity index 100% rename from doc/error.png rename to doc/lifecycle/png/error.png diff --git a/doc/eventtask.png b/doc/lifecycle/png/eventtask.png similarity index 100% rename from doc/eventtask.png rename to doc/lifecycle/png/eventtask.png diff --git a/doc/microtask.png b/doc/lifecycle/png/microtask.png similarity index 100% rename from doc/microtask.png rename to doc/lifecycle/png/microtask.png diff --git a/doc/non-periodical-macrotask.png b/doc/lifecycle/png/non-periodical-macrotask.png similarity index 100% rename from doc/non-periodical-macrotask.png rename to doc/lifecycle/png/non-periodical-macrotask.png diff --git a/doc/override-task.png b/doc/lifecycle/png/override-task.png similarity index 100% rename from doc/override-task.png rename to doc/lifecycle/png/override-task.png diff --git a/doc/periodical-macrotask.png b/doc/lifecycle/png/periodical-macrotask.png similarity index 100% rename from doc/periodical-macrotask.png rename to doc/lifecycle/png/periodical-macrotask.png diff --git a/doc/reschedule-task.png b/doc/lifecycle/png/reschedule-task.png similarity index 100% rename from doc/reschedule-task.png rename to doc/lifecycle/png/reschedule-task.png diff --git a/doc/error.puml b/doc/lifecycle/puml/error.puml similarity index 100% rename from doc/error.puml rename to doc/lifecycle/puml/error.puml diff --git a/doc/eventtask.puml b/doc/lifecycle/puml/eventtask.puml similarity index 100% rename from doc/eventtask.puml rename to doc/lifecycle/puml/eventtask.puml diff --git a/doc/microtask.puml b/doc/lifecycle/puml/microtask.puml similarity index 100% rename from doc/microtask.puml rename to doc/lifecycle/puml/microtask.puml diff --git a/doc/non-periodical-macrotask.puml b/doc/lifecycle/puml/non-periodical-macrotask.puml similarity index 100% rename from doc/non-periodical-macrotask.puml rename to doc/lifecycle/puml/non-periodical-macrotask.puml diff --git a/doc/override-task.puml b/doc/lifecycle/puml/override-task.puml similarity index 100% rename from doc/override-task.puml rename to doc/lifecycle/puml/override-task.puml diff --git a/doc/periodical-macrotask.puml b/doc/lifecycle/puml/periodical-macrotask.puml similarity index 100% rename from doc/periodical-macrotask.puml rename to doc/lifecycle/puml/periodical-macrotask.puml diff --git a/doc/reschedule-task.puml b/doc/lifecycle/puml/reschedule-task.puml similarity index 100% rename from doc/reschedule-task.puml rename to doc/lifecycle/puml/reschedule-task.puml diff --git a/doc/task.md b/doc/lifecycle/task.md similarity index 100% rename from doc/task.md rename to doc/lifecycle/task.md diff --git a/gulpfile.js b/gulpfile.js index dc0490804..ee0956804 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -404,9 +404,8 @@ function nodeTest(specFiles, cb) { require('./build/lib/node/rollup-main'); var args = process.argv; if (args.length > 3) { - require('./build/test/test-env-setup-jasmine' + args[3]); + require('./build/test/env/config/test-env-setup-jasmine' + args[3]); } - var JasmineRunner = require('jasmine'); var JasmineRunner = require('jasmine'); var jrunner = new JasmineRunner(); @@ -433,12 +432,12 @@ function nodeTest(specFiles, cb) { } gulp.task('test/node', ['compile-node'], function(cb) { - var specFiles = ['build/test/node_entry_point.js']; + var specFiles = ['build/test/env/node/node_entry_point.js']; nodeTest(specFiles, cb); }); gulp.task('test/bluebird', ['compile-node'], function(cb) { - var specFiles = ['build/test/node_bluebird_entry_point.js']; + var specFiles = ['build/test/env/node/node_bluebird_entry_point.js']; nodeTest(specFiles, cb); }); @@ -498,7 +497,7 @@ gulp.task('changelog', () => { // run promise aplus test gulp.task('promisetest', ['build/zone-node.js'], (cb) => { const promisesAplusTests = require('promises-aplus-tests'); - const adapter = require('./promise-adapter'); + const adapter = require('./test/spec/promise/promise-adapter'); promisesAplusTests(adapter, {reporter: 'dot'}, function(err) { if (err) { cb(err); @@ -510,8 +509,8 @@ gulp.task('promisetest', ['build/zone-node.js'], (cb) => { // check dist file size limitation gulp.task('filesize', ['build'], (cb) => { - const checker = require('./check-file-size'); - const result = checker(require('./file-size-limit.json')); + const checker = require('./scripts/size/check-file-size'); + const result = checker(require('./scripts/size/file-size-limit.json')); if (result) { cb(); } else { diff --git a/karma-dist-sauce-jasmine3.conf.js b/karma-dist-sauce-jasmine3.conf.js deleted file mode 100644 index 550d2ad94..000000000 --- a/karma-dist-sauce-jasmine3.conf.js +++ /dev/null @@ -1,12 +0,0 @@ -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -module.exports = function (config) { - require('./karma-dist-jasmine.conf.js')(config); - require('./sauce.conf')(config, ['SL_IOS9', 'SL_CHROME', 'SL_FIREFOX_54', 'SL_SAFARI8', 'SL_SAFARI9', 'SL_SAFARI10', 'SL_IOS8', 'SL_IOS9', 'SL_IOS10', 'SL_IE9', 'SL_IE10', 'SL_IE11', 'SL_MSEDGE15', 'SL_ANDROID4.4', 'SL_ANDROID5.1']) -}; diff --git a/lib/jasmine/jasmine-patch.ts b/lib/jasmine/jasmine-patch.ts index 518c5404a..f11ed2843 100644 --- a/lib/jasmine/jasmine-patch.ts +++ b/lib/jasmine/jasmine-patch.ts @@ -8,6 +8,7 @@ 'use strict'; import {patchJasmineClock} from './jasmine.clock'; +import { mappingMochaMethods } from './mocha-bridge/mocha.bdd'; Zone.__load_patch('jasmine', (global: any) => { const __extends = function(d: any, b: any) { for (const p in b) @@ -24,7 +25,7 @@ Zone.__load_patch('jasmine', (global: any) => { // not using jasmine, just return; return; } - if ((jasmine as any)['__zone_symbol__isMochaBridge']) { + if ((jasmine as any)['__zone_symbol__isBridge']) { // jasmine is a mock bridge return; } @@ -61,9 +62,6 @@ Zone.__load_patch('jasmine', (global: any) => { jasmineEnv[symbol(methodName)] = originalJasmineFn; jasmineEnv[methodName] = function( description: string, specDefinitions: Function, timeout: number) { - if (typeof timeout !== 'number') { - timeout = (jasmine as any)[symbol('mochaTimeout')]; - } const wrappedSpecDef = wrapTestInZone(specDefinitions); return originalJasmineFn.apply( this, @@ -71,13 +69,10 @@ Zone.__load_patch('jasmine', (global: any) => { [description, wrappedSpecDef]); }; }); - ['beforeEach', 'afterEach'].forEach(methodName => { + ['beforeAll', 'afterAll', 'beforeEach', 'afterEach'].forEach(methodName => { let originalJasmineFn: Function = jasmineEnv[methodName]; jasmineEnv[symbol(methodName)] = originalJasmineFn; jasmineEnv[methodName] = function(specDefinitions: Function, timeout: number) { - if (typeof timeout !== 'number') { - timeout = (jasmine as any)[symbol('mochaTimeout')]; - } const wrappedSpecDef = wrapTestInZone(specDefinitions); return originalJasmineFn.apply( this, typeof timeout === 'number' ? [wrappedSpecDef, timeout] : [wrappedSpecDef]); @@ -91,19 +86,7 @@ Zone.__load_patch('jasmine', (global: any) => { */ function wrapDescribeInZone(describeBody: Function): Function { return function() { - (jasmine as any)[symbol('mochaTimeout')] = null; - if (this && !this.timeout) { - this.timeout = function(timeout: number) { - (jasmine as any)[symbol('mochaTimeout')] = timeout; - } - } - if (this && !this.skip) { - this.skip = function() { - if (typeof global['pending'] === 'function') { - global['pending'](); - } - } - } + mappingMochaMethods(jasmine, global, this); return syncZone.run(describeBody, this, (arguments as any) as any[]); }; } @@ -119,6 +102,7 @@ Zone.__load_patch('jasmine', (global: any) => { testBody = fakeAsyncModule.fakeAsync(testBody); } } + mappingMochaMethods(jasmine, global, applyThis); if (done) { return testProxyZone.run(testBody, applyThis, [done]); } else { @@ -170,6 +154,10 @@ Zone.__load_patch('jasmine', (global: any) => { // All functions are done, clear the test zone. this.testProxyZone = null; this.testProxyZoneSpec = null; + const originalTimeout = (jasmine as any)['__zone_symbol__DEFAULT_TIMEOUT_INTERVAL']; + if (typeof originalTimeout === 'number') { + jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout; + } ambientZone.scheduleMicroTask('jasmine.onComplete', fn); })(attrs.onComplete); diff --git a/lib/jasmine/mocha-bridge/mocha.bdd.ts b/lib/jasmine/mocha-bridge/mocha.bdd.ts index ac6be8099..287932ce1 100644 --- a/lib/jasmine/mocha-bridge/mocha.bdd.ts +++ b/lib/jasmine/mocha-bridge/mocha.bdd.ts @@ -25,4 +25,21 @@ export function mappingBDD(Mocha: any, jasmine: any, global: any) { target[mocha] = global[jasmine]; } }); +} + +const symbol = Zone.__symbol__; +export function mappingMochaMethods(jasmine: any, global: any, context: any) { + if (context && !context.timeout) { + context.timeout = function (timeout: number) { + (jasmine as any)['__zone_symbol__DEFAULT_TIMEOUT_INTERVAL'] = jasmine.DEFAULT_TIMEOUT_INTERVAL; + jasmine.DEFAULT_TIMEOUT_INTERVAL = timeout; + }; + } + if (context && !context.skip) { + context.skip = function () { + if (typeof global['pending'] === 'function') { + global['pending'](); + } + }; + } } \ No newline at end of file diff --git a/lib/jasmine/mocha-bridge/mocha.ts b/lib/jasmine/mocha-bridge/mocha.ts index c62f75efe..92106048a 100644 --- a/lib/jasmine/mocha-bridge/mocha.ts +++ b/lib/jasmine/mocha-bridge/mocha.ts @@ -11,6 +11,7 @@ Zone.__load_patch('mocha-bridge', (global: any) => { return; } global.Mocha = {}; - global.Mocha['__zone_symbol__isJasmineBridge'] = true; + // set a flag to tell global.Mocha is a mock. + global.Mocha['__zone_symbol__isBridge'] = true; mappingBDD(global.Mocha, global.jasmine, global); }); \ No newline at end of file diff --git a/lib/mocha/jasmine-bridge/jasmine.bdd.ts b/lib/mocha/jasmine-bridge/jasmine.bdd.ts index 10c8a73ff..b07e16082 100644 --- a/lib/mocha/jasmine-bridge/jasmine.bdd.ts +++ b/lib/mocha/jasmine-bridge/jasmine.bdd.ts @@ -18,7 +18,7 @@ export function mappingBDD(jasmine: any, Mocha: any, global: any) { const chains = mocha.split('.'); let mochaMethod: any = null; for (let i = 0; i < chains.length; i++) { - mochaMethod = mochaMethod ? mochaMethod[chains[i]] : Mocha[chains[i]]; + mochaMethod = mochaMethod ? mochaMethod[chains[i]] : global[chains[i]]; } global[map.jasmine] = jasmine[map.jasmine] = function() { const args = Array.prototype.slice.call(arguments); diff --git a/lib/mocha/jasmine-bridge/jasmine.ts b/lib/mocha/jasmine-bridge/jasmine.ts index 56d0a4128..84e071b3e 100644 --- a/lib/mocha/jasmine-bridge/jasmine.ts +++ b/lib/mocha/jasmine-bridge/jasmine.ts @@ -22,6 +22,7 @@ Zone.__load_patch('jasmine2mocha', (global: any) => { } // create a jasmine global object jasmine = global['jasmine'] = {}; + jasmine['__zone_symbol__isBridge'] = true; // BDD mapping mappingBDD(jasmine, global.Mocha, global); diff --git a/lib/mocha/mocha-patch.ts b/lib/mocha/mocha-patch.ts index f60e404f4..72cf60878 100644 --- a/lib/mocha/mocha-patch.ts +++ b/lib/mocha/mocha-patch.ts @@ -15,7 +15,7 @@ Zone.__load_patch('Mocha', (global: any, Zone: ZoneType, api: _ZonePrivate) => { return; } - if (Mocha['__zone_symbol__isJasmineBridge']) { + if (Mocha['__zone_symbol__isBridge']) { return; } diff --git a/package.json b/package.json index da9a05043..0511c2cd6 100644 --- a/package.json +++ b/package.json @@ -19,21 +19,21 @@ "ci": "npm run lint && npm run format && npm run promisetest && npm run test:single && npm run test-node", "closure:test": "scripts/closure/closure_compiler.sh", "format": "gulp format:enforce", - "karma-jasmine": "karma start karma-build-jasmine.conf.js", - "karma-jasmine:phantomjs": "karma start karma-build-jasmine-phantomjs.conf.js --single-run", - "karma-jasmine:single": "karma start karma-build-jasmine.conf.js --single-run", + "karma-jasmine": "karma start ./test/karma/common/build/karma-build-jasmine.conf.js", + "karma-jasmine:phantomjs": "karma start ./test/karma/common/build/karma-build-jasmine-phantomjs.conf.js --single-run", + "karma-jasmine:single": "karma start ./test/karma/common/build/karma-build-jasmine.conf.js --single-run", "karma-jasmine:autoclose": "npm run karma-jasmine:single && npm run ws-client", "karma-jasmine-phantomjs:autoclose": "npm run karma-jasmine:phantomjs && npm run ws-client", "lint": "gulp lint", "prepublish": "tsc && gulp build", "promisetest": "gulp promisetest", - "promisefinallytest": "mocha promise.finally.spec.js", + "promisefinallytest": "mocha ./test/spec/promise/promise.finally.spec.js", "webdriver-start": "webdriver-manager update && webdriver-manager start", - "webdriver-http": "node simple-server.js", - "webdriver-test": "node test/webdriver/test.js", - "webdriver-sauce-test": "node test/webdriver/test.sauce.js", - "ws-client": "node ./test/ws-client.js", - "ws-server": "node ./test/ws-server.js", + "webdriver-http": "node test/spec/webdriver/simple-server.js", + "webdriver-test": "node test/spec/webdriver/test.js", + "webdriver-sauce-test": "node test/spec/webdriver/test.sauce.js", + "ws-client": "node ./test/env/websocket/ws-client.js", + "ws-server": "node ./test/env/websocket/ws-server.js", "tsc": "tsc -p .", "tsc:w": "tsc -w -p .", "tslint": "tslint -c tslint.json 'lib/**/*.ts'", @@ -41,12 +41,12 @@ "test:phantomjs": "npm run tsc && concurrently \"npm run tsc:w\" \"npm run ws-server\" \"npm run karma-jasmine:phantomjs\"", "test:phantomjs-single": "npm run tsc && concurrently \"npm run ws-server\" \"npm run karma-jasmine-phantomjs:autoclose\"", "test:single": "npm run tsc && concurrently \"npm run ws-server\" \"npm run karma-jasmine:autoclose\"", - "test-dist": "concurrently \"npm run tsc:w\" \"npm run ws-server\" \"karma start karma-dist-jasmine.conf.js\"", + "test-dist": "concurrently \"npm run tsc:w\" \"npm run ws-server\" \"karma start ./test/karma/common/dist/karma-dist-jasmine.conf.js\"", "test-node": "gulp test/node", "test-bluebird": "gulp test/bluebird", - "test-mocha": "npm run tsc && concurrently \"npm run tsc:w\" \"npm run ws-server\" \"karma start karma-build-mocha.conf.js\"", - "test-mocha-jasmine-bridge-browser": "npm run tsc && concurrently \"npm run ws-server\" \"karma start karma-build-mocha-jasmine-bridge.conf.js\"", - "test-mocha-jasmine-bridge-node": "npm run tsc && mocha ./build/test/mocha/mocha-node-test-entry-point.js", + "test-mocha": "npm run tsc && concurrently \"npm run tsc:w\" \"npm run ws-server\" \"karma start ./test/karma/common/build/karma-build-mocha.conf.js\"", + "test-mocha-jasmine-bridge-browser": "npm run tsc && concurrently \"npm run ws-server\" \"karma start ./test/karma/common/build/karma-build-mocha-jasmine-bridge.conf.js\"", + "test-mocha-jasmine-bridge-node": "npm run tsc && mocha ./build/test/spec/mocha/mocha-node-test-entry-point.js", "serve": "python -m SimpleHTTPServer 8000" }, "repository": { diff --git a/promise.finally.spec.js b/promise.finally.spec.js deleted file mode 100644 index 35a5c4e57..000000000 --- a/promise.finally.spec.js +++ /dev/null @@ -1,345 +0,0 @@ -'use strict'; - -var assert = require('assert'); -var adapter = require('./promise-adapter'); -var P = global['__zone_symbol__Promise']; - -var someRejectionReason = {message: 'some rejection reason'}; -var anotherReason = {message: 'another rejection reason'}; -process.on('unhandledRejection', function(reason, promise) { - console.log('unhandledRejection', reason); -}); - -describe('mocha promise sanity check', () => { - it('passes with a resolved promise', () => { - return P.resolve(3); - }); - - it('passes with a rejected then resolved promise', () => { - return P.reject(someRejectionReason).catch(x => 'this should be resolved'); - }); - - var ifPromiseIt = P === Promise ? it : it.skip; - ifPromiseIt('is the native Promise', () => { - assert.equal(P, Promise); - }); -}); - -describe('onFinally', () => { - describe('no callback', () => { - specify('from resolved', (done) => { - adapter.resolved(3) - .then((x) => { - assert.strictEqual(x, 3); - return x; - }) - .finally() - .then(function onFulfilled(x) { - assert.strictEqual(x, 3); - done(); - }, function onRejected() { - done(new Error('should not be called')); - }); - }); - - specify('from rejected', (done) => { - adapter.rejected(someRejectionReason) - .catch((e) => { - assert.strictEqual(e, someRejectionReason); - throw e; - }) - .finally() - .then(function onFulfilled() { - done(new Error('should not be called')); - }, function onRejected(reason) { - assert.strictEqual(reason, someRejectionReason); - done(); - }); - }); - }); - - describe('throws an exception', () => { - specify('from resolved', (done) => { - adapter.resolved(3) - .then((x) => { - assert.strictEqual(x, 3); - return x; - }) - .finally(function onFinally() { - assert(arguments.length === 0); - throw someRejectionReason; - }).then(function onFulfilled() { - done(new Error('should not be called')); - }, function onRejected(reason) { - assert.strictEqual(reason, someRejectionReason); - done(); - }); - }); - - specify('from rejected', (done) => { - adapter.rejected(anotherReason).finally(function onFinally() { - assert(arguments.length === 0); - throw someRejectionReason; - }).then(function onFulfilled() { - done(new Error('should not be called')); - }, function onRejected(reason) { - assert.strictEqual(reason, someRejectionReason); - done(); - }); - }); - }); - - describe('returns a non-promise', () => { - specify('from resolved', (done) => { - adapter.resolved(3) - .then((x) => { - assert.strictEqual(x, 3); - return x; - }) - .finally(function onFinally() { - assert(arguments.length === 0); - return 4; - }).then(function onFulfilled(x) { - assert.strictEqual(x, 3); - done(); - }, function onRejected() { - done(new Error('should not be called')); - }); - }); - - specify('from rejected', (done) => { - adapter.rejected(anotherReason) - .catch((e) => { - assert.strictEqual(e, anotherReason); - throw e; - }) - .finally(function onFinally() { - assert(arguments.length === 0); - throw someRejectionReason; - }).then(function onFulfilled() { - done(new Error('should not be called')); - }, function onRejected(e) { - assert.strictEqual(e, someRejectionReason); - done(); - }); - }); - }); - - describe('returns a pending-forever promise', () => { - specify('from resolved', (done) => { - var timeout; - adapter.resolved(3) - .then((x) => { - assert.strictEqual(x, 3); - return x; - }) - .finally(function onFinally() { - assert(arguments.length === 0); - timeout = setTimeout(done, 0.1e3); - return new P(() => {}); // forever pending - }).then(function onFulfilled(x) { - clearTimeout(timeout); - done(new Error('should not be called')); - }, function onRejected() { - clearTimeout(timeout); - done(new Error('should not be called')); - }); - }); - - specify('from rejected', (done) => { - var timeout; - adapter.rejected(someRejectionReason) - .catch((e) => { - assert.strictEqual(e, someRejectionReason); - throw e; - }) - .finally(function onFinally() { - assert(arguments.length === 0); - timeout = setTimeout(done, 0.1e3); - return new P(() => {}); // forever pending - }).then(function onFulfilled(x) { - clearTimeout(timeout); - done(new Error('should not be called')); - }, function onRejected() { - clearTimeout(timeout); - done(new Error('should not be called')); - }); - }); - }); - - describe('returns an immediately-fulfilled promise', () => { - specify('from resolved', (done) => { - adapter.resolved(3) - .then((x) => { - assert.strictEqual(x, 3); - return x; - }) - .finally(function onFinally() { - assert(arguments.length === 0); - return adapter.resolved(4); - }).then(function onFulfilled(x) { - assert.strictEqual(x, 3); - done(); - }, function onRejected() { - done(new Error('should not be called')); - }); - }); - - specify('from rejected', (done) => { - adapter.rejected(someRejectionReason) - .catch((e) => { - assert.strictEqual(e, someRejectionReason); - throw e; - }) - .finally(function onFinally() { - assert(arguments.length === 0); - return adapter.resolved(4); - }).then(function onFulfilled() { - done(new Error('should not be called')); - }, function onRejected(e) { - assert.strictEqual(e, someRejectionReason); - done(); - }); - }); - }); - - describe('returns an immediately-rejected promise', () => { - specify('from resolved ', (done) => { - adapter.resolved(3) - .then((x) => { - assert.strictEqual(x, 3); - return x; - }) - .finally(function onFinally() { - assert(arguments.length === 0); - return adapter.rejected(4); - }).then(function onFulfilled(x) { - done(new Error('should not be called')); - }, function onRejected(e) { - assert.strictEqual(e, 4); - done(); - }); - }); - - specify('from rejected', (done) => { - const newReason = {}; - adapter.rejected(someRejectionReason) - .catch((e) => { - assert.strictEqual(e, someRejectionReason); - throw e; - }) - .finally(function onFinally() { - assert(arguments.length === 0); - return adapter.rejected(newReason); - }).then(function onFulfilled(x) { - done(new Error('should not be called')); - }, function onRejected(e) { - assert.strictEqual(e, newReason); - done(); - }); - }); - }); - - describe('returns a fulfilled-after-a-second promise', () => { - specify('from resolved', (done) => { - var timeout; - adapter.resolved(3) - .then((x) => { - assert.strictEqual(x, 3); - return x; - }) - .finally(function onFinally() { - assert(arguments.length === 0); - timeout = setTimeout(done, 1.5e3); - return new P((resolve) => { - setTimeout(() => resolve(4), 1e3); - }); - }).then(function onFulfilled(x) { - clearTimeout(timeout); - assert.strictEqual(x, 3); - done(); - }, function onRejected() { - clearTimeout(timeout); - done(new Error('should not be called')); - }); - }); - - specify('from rejected', (done) => { - var timeout; - adapter.rejected(3) - .catch((e) => { - assert.strictEqual(e, 3); - throw e; - }) - .finally(function onFinally() { - assert(arguments.length === 0); - timeout = setTimeout(done, 1.5e3); - return new P((resolve) => { - setTimeout(() => resolve(4), 1e3); - }); - }).then(function onFulfilled() { - clearTimeout(timeout); - done(new Error('should not be called')); - }, function onRejected(e) { - clearTimeout(timeout); - assert.strictEqual(e, 3); - done(); - }); - }); - }); - - describe('returns a rejected-after-a-second promise', () => { - specify('from resolved', (done) => { - var timeout; - adapter.resolved(3) - .then((x) => { - assert.strictEqual(x, 3); - return x; - }) - .finally(function onFinally() { - assert(arguments.length === 0); - timeout = setTimeout(done, 1.5e3); - return new P((resolve, reject) => { - setTimeout(() => reject(4), 1e3); - }); - }).then(function onFulfilled() { - clearTimeout(timeout); - done(new Error('should not be called')); - }, function onRejected(e) { - clearTimeout(timeout); - assert.strictEqual(e, 4); - done(); - }); - }); - - specify('from rejected', (done) => { - var timeout; - adapter.rejected(someRejectionReason) - .catch((e) => { - assert.strictEqual(e, someRejectionReason); - throw e; - }) - .finally(function onFinally() { - assert(arguments.length === 0); - timeout = setTimeout(done, 1.5e3); - return new P((resolve, reject) => { - setTimeout(() => reject(anotherReason), 1e3); - }); - }).then(function onFulfilled() { - clearTimeout(timeout); - done(new Error('should not be called')); - }, function onRejected(e) { - clearTimeout(timeout); - assert.strictEqual(e, anotherReason); - done(); - }); - }); - }); - - specify('has the correct property descriptor', () => { - var descriptor = Object.getOwnPropertyDescriptor(Promise.prototype, 'finally'); - - assert.strictEqual(descriptor.writable, true); - assert.strictEqual(descriptor.configurable, true); - }); -}); \ No newline at end of file diff --git a/scripts/closure/closure_flagfile b/scripts/closure/closure_flagfile index 524aa0ef6..e83484162 100644 --- a/scripts/closure/closure_flagfile +++ b/scripts/closure/closure_flagfile @@ -1,5 +1,5 @@ --compilation_level ADVANCED_OPTIMIZATIONS --js_output_file "build/closure/closure-bundle.js" --rewrite_polyfills false ---js "build/test/closure/zone.closure.js" +--js "build/test/spec/closure/zone.closure.js" --formatting PRETTY_PRINT \ No newline at end of file diff --git a/check-file-size.js b/scripts/size/check-file-size.js similarity index 100% rename from check-file-size.js rename to scripts/size/check-file-size.js diff --git a/file-size-limit.json b/scripts/size/file-size-limit.json similarity index 100% rename from file-size-limit.json rename to scripts/size/file-size-limit.json diff --git a/test/browser-zone-setup.ts b/test/browser-zone-setup.ts deleted file mode 100644 index 8b812dc1c..000000000 --- a/test/browser-zone-setup.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ -if (typeof window !== 'undefined') { - (window as any)['__Zone_enable_cross_context_check'] = true; - (window as any)['__zone_symbol__fakeAsyncPatchLock'] = true; -} -import '../lib/common/to-string'; -import '../lib/browser/browser'; -import '../lib/browser/webapis-user-media'; -import '../lib/testing/zone-testing'; -import '../lib/zone-spec/task-tracking'; -import '../lib/zone-spec/wtf'; -import '../lib/extra/cordova'; -import '../lib/testing/promise-testing'; -import '../lib/testing/async-testing'; -import '../lib/testing/fake-async'; -import '../lib/browser/webapis-resize-observer'; diff --git a/test/browser_entry_point.ts b/test/browser_entry_point.ts deleted file mode 100644 index 73e95d381..000000000 --- a/test/browser_entry_point.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -// List all tests here: -import './common_tests'; -import './browser/browser.spec'; -import './browser/define-property.spec'; -import './browser/element.spec'; -import './browser/FileReader.spec'; -// import './browser/geolocation.spec.manual'; -import './browser/HTMLImports.spec'; -import './browser/MutationObserver.spec'; -import './browser/registerElement.spec'; -import './browser/requestAnimationFrame.spec'; -import './browser/WebSocket.spec'; -import './browser/XMLHttpRequest.spec'; -import './browser/MediaQuery.spec'; -import './browser/Notification.spec'; -import './browser/Worker.spec'; -import './jasmine-patch.spec'; -import './extra/cordova.spec'; diff --git a/test/common_tests.ts b/test/common_tests.ts deleted file mode 100644 index 2fbb7ecfd..000000000 --- a/test/common_tests.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import './common/microtasks.spec'; -import './common/zone.spec'; -import './common/task.spec'; -import './common/util.spec'; -import './common/Promise.spec'; -import './common/Error.spec'; -import './common/setInterval.spec'; -import './common/setTimeout.spec'; -import './common/toString.spec'; -import './zone-spec/long-stack-trace-zone.spec'; -import './zone-spec/async-test.spec'; -import './zone-spec/sync-test.spec'; -import './zone-spec/fake-async-test.spec'; -import './zone-spec/proxy.spec'; -import './zone-spec/task-tracking.spec'; -import './rxjs/rxjs.spec'; - -Error.stackTraceLimit = Number.POSITIVE_INFINITY; diff --git a/test/env/browser/browser-zone-setup.ts b/test/env/browser/browser-zone-setup.ts new file mode 100644 index 000000000..30c3e725e --- /dev/null +++ b/test/env/browser/browser-zone-setup.ts @@ -0,0 +1,22 @@ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ +if (typeof window !== 'undefined') { + (window as any)['__Zone_enable_cross_context_check'] = true; + (window as any)['__zone_symbol__fakeAsyncPatchLock'] = true; +} +import '../../../lib/common/to-string'; +import '../../../lib/browser/browser'; +import '../../../lib/browser/webapis-user-media'; +import '../../../lib/testing/zone-testing'; +import '../../../lib/zone-spec/task-tracking'; +import '../../../lib/zone-spec/wtf'; +import '../../../lib/extra/cordova'; +import '../../../lib/testing/promise-testing'; +import '../../../lib/testing/async-testing'; +import '../../../lib/testing/fake-async'; +import '../../../lib/browser/webapis-resize-observer'; diff --git a/test/env/browser/browser_entry_point.ts b/test/env/browser/browser_entry_point.ts new file mode 100644 index 000000000..675eeeda7 --- /dev/null +++ b/test/env/browser/browser_entry_point.ts @@ -0,0 +1,25 @@ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +// List all tests here: +import '../common/common_tests'; +import '../../spec/browser/browser.spec'; +import '../../spec/browser/define-property.spec'; +import '../../spec/browser/element.spec'; +import '../../spec/browser/FileReader.spec'; +// import '../../spec/browser/geolocation.spec.manual'; +import '../../spec/browser/HTMLImports.spec'; +import '../../spec/browser/MutationObserver.spec'; +import '../../spec/browser/registerElement.spec'; +import '../../spec/browser/requestAnimationFrame.spec'; +import '../../spec/browser/WebSocket.spec'; +import '../../spec/browser/XMLHttpRequest.spec'; +import '../../spec/browser/MediaQuery.spec'; +import '../../spec/browser/Notification.spec'; +import '../../spec/browser/Worker.spec'; +import '../../spec/extra/cordova.spec'; diff --git a/test/main.ts b/test/env/browser/main.ts similarity index 78% rename from test/main.ts rename to test/env/browser/main.ts index 69e25a3c5..7b4ca188c 100644 --- a/test/main.ts +++ b/test/env/browser/main.ts @@ -28,16 +28,16 @@ if ((window as any)[(Zone as any).__symbol__('setTimeout')]) { } else { // this means that Zone has not patched the browser yet, which means we must be running in // build mode and need to load the browser patch. - browserPatchedPromise = System.import('/base/build/test/browser-zone-setup'); + browserPatchedPromise = System.import('/base/build/test/env/browser/browser-zone-setup'); } browserPatchedPromise.then(() => { let testFrameworkPatch = typeof (window as any).Mocha !== 'undefined' ? - '/base/build/test/test-env-setup-mocha' : - '/base/build/test/test-env-setup-jasmine'; + '/base/build/test/env/config/test-env-setup-mocha' : + '/base/build/test/env/config/test-env-setup-jasmine'; // Setup test environment - const entryPoint = - (window as any)['__zone_symbol__test_entry_point'] || '/base/build/test/browser_entry_point'; + const entryPoint = (window as any)['__zone_symbol__test_entry_point'] || + '/base/build/test/env/browser/browser_entry_point'; System.import(testFrameworkPatch).then(() => { System.import(entryPoint) .then( diff --git a/test/env/common/common_tests.ts b/test/env/common/common_tests.ts new file mode 100644 index 000000000..b5b3a4ccf --- /dev/null +++ b/test/env/common/common_tests.ts @@ -0,0 +1,28 @@ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +import '../../spec/common/microtasks.spec'; +import '../../spec/common/zone.spec'; +import '../../spec/common/task.spec'; +import '../../spec/common/util.spec'; +import '../../spec/common/Promise.spec'; +import '../../spec/common/Error.spec'; +import '../../spec/common/setInterval.spec'; +import '../../spec/common/setTimeout.spec'; +import '../../spec/common/toString.spec'; +import '../../spec/zone-spec/long-stack-trace-zone.spec'; +import '../../spec/zone-spec/async-test.spec'; +import '../../spec/zone-spec/sync-test.spec'; +import '../../spec/zone-spec/fake-async-test.spec'; +import '../../spec/zone-spec/proxy.spec'; +import '../../spec/zone-spec/task-tracking.spec'; +import '../../spec/rxjs/rxjs.spec'; +import '../../spec/jasmine/jasmine-patch.spec'; +import '../../spec/mocha/mocha-patch.spec'; + +Error.stackTraceLimit = Number.POSITIVE_INFINITY; diff --git a/test/saucelabs.js b/test/env/config/saucelabs.js similarity index 100% rename from test/saucelabs.js rename to test/env/config/saucelabs.js diff --git a/test/test-env-setup-jasmine-no-patch-clock.ts b/test/env/config/test-env-setup-jasmine-no-patch-clock.ts similarity index 100% rename from test/test-env-setup-jasmine-no-patch-clock.ts rename to test/env/config/test-env-setup-jasmine-no-patch-clock.ts diff --git a/test/test-env-setup-jasmine.ts b/test/env/config/test-env-setup-jasmine.ts similarity index 100% rename from test/test-env-setup-jasmine.ts rename to test/env/config/test-env-setup-jasmine.ts diff --git a/test/test-env-setup-mocha.ts b/test/env/config/test-env-setup-mocha.ts similarity index 100% rename from test/test-env-setup-mocha.ts rename to test/env/config/test-env-setup-mocha.ts diff --git a/test/env/node/node_bluebird_entry_point.ts b/test/env/node/node_bluebird_entry_point.ts new file mode 100644 index 000000000..467bd5f57 --- /dev/null +++ b/test/env/node/node_bluebird_entry_point.ts @@ -0,0 +1,32 @@ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +// Must be loaded before zone loads, so that zone can detect WTF. +import '../polyfills/wtf_mock'; +import '../polyfills/test_fake_polyfill'; + +// Setup tests for Zone without microtask support +import '../../../lib/zone'; +import '../../../lib/common/promise'; +import '../../../lib/common/to-string'; +import '../../../lib/node/node'; +import '../../../lib/zone-spec/async-test'; +import '../../../lib/zone-spec/fake-async-test'; +import '../../../lib/zone-spec/long-stack-trace'; +import '../../../lib/zone-spec/proxy'; +import '../../../lib/zone-spec/sync-test'; +import '../../../lib/zone-spec/task-tracking'; +import '../../../lib/zone-spec/wtf'; +import '../../../lib/rxjs/rxjs'; + +import '../../../lib/testing/promise-testing'; +// Setup test environment +import '../config/test-env-setup-jasmine'; + +// List all tests here: +import '../../spec/extra/bluebird.spec'; \ No newline at end of file diff --git a/test/node_entry_point.ts b/test/env/node/node_entry_point.ts similarity index 56% rename from test/node_entry_point.ts rename to test/env/node/node_entry_point.ts index fd521eb92..8ce12650f 100644 --- a/test/node_entry_point.ts +++ b/test/env/node/node_entry_point.ts @@ -11,21 +11,21 @@ if (typeof global !== 'undefined' && (global as any)['__zone_symbol__fakeAsyncPatchLock'] !== false) { (global as any)['__zone_symbol__fakeAsyncPatchLock'] = true; } -import './wtf_mock'; -import './test_fake_polyfill'; +import '../polyfills/wtf_mock'; +import '../polyfills/test_fake_polyfill'; // Setup tests for Zone without microtask support -import '../lib/testing/zone-testing'; -import '../lib/zone-spec/task-tracking'; -import '../lib/zone-spec/wtf'; -import '../lib/rxjs/rxjs'; +import '../../../lib/testing/zone-testing'; +import '../../../lib/zone-spec/task-tracking'; +import '../../../lib/zone-spec/wtf'; +import '../../../lib/rxjs/rxjs'; -import '../lib/testing/promise-testing'; -import '../lib/testing/async-testing'; -import '../lib/testing/fake-async'; +import '../../../lib/testing/promise-testing'; +import '../../../lib/testing/async-testing'; +import '../../../lib/testing/fake-async'; // Setup test environment -import './test-env-setup-jasmine'; +import '../config/test-env-setup-jasmine'; // List all tests here: -import './common_tests'; +import '../common/common_tests'; import './node_tests'; diff --git a/test/env/node/node_tests.ts b/test/env/node/node_tests.ts new file mode 100644 index 000000000..33c282594 --- /dev/null +++ b/test/env/node/node_tests.ts @@ -0,0 +1,15 @@ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +import '../../spec/node/events.spec'; +import '../../spec/node/fs.spec'; +import '../../spec/node/process.spec'; +import '../../spec/node/Error.spec'; +import '../../spec/node/crypto.spec'; +import '../../spec/node/http.spec'; +import '../../spec/node/console.spec'; diff --git a/test/test_fake_polyfill.ts b/test/env/polyfills/test_fake_polyfill.ts similarity index 100% rename from test/test_fake_polyfill.ts rename to test/env/polyfills/test_fake_polyfill.ts diff --git a/test/wtf_mock.ts b/test/env/polyfills/wtf_mock.ts similarity index 100% rename from test/wtf_mock.ts rename to test/env/polyfills/wtf_mock.ts diff --git a/test/ws-client.js b/test/env/websocket/ws-client.js similarity index 100% rename from test/ws-client.js rename to test/env/websocket/ws-client.js diff --git a/test/ws-server.js b/test/env/websocket/ws-server.js similarity index 100% rename from test/ws-server.js rename to test/env/websocket/ws-server.js diff --git a/test/ws-webworker-context.ts b/test/env/websocket/ws-webworker-context.ts similarity index 58% rename from test/ws-webworker-context.ts rename to test/env/websocket/ws-webworker-context.ts index b52632ea4..1999d4c14 100644 --- a/test/ws-webworker-context.ts +++ b/test/env/websocket/ws-webworker-context.ts @@ -8,6 +8,6 @@ declare function importScripts(path: string): void; - importScripts('/base/build/lib/zone.js'); - importScripts('/base/node_modules/systemjs/dist/system.src.js'); - importScripts('/base/build/test/zone_worker_entry_point.js'); +importScripts('/base/build/lib/zone.js'); +importScripts('/base/node_modules/systemjs/dist/system.src.js'); +importScripts('/base/build/test/env/websocket/zone_worker_entry_point.js'); diff --git a/test/zone_worker_entry_point.ts b/test/env/websocket/zone_worker_entry_point.ts similarity index 92% rename from test/zone_worker_entry_point.ts rename to test/env/websocket/zone_worker_entry_point.ts index 2c35278c1..d73eade24 100644 --- a/test/zone_worker_entry_point.ts +++ b/test/env/websocket/zone_worker_entry_point.ts @@ -8,7 +8,7 @@ // Setup tests for Zone without microtask support System.config({defaultJSExtensions: true}); -System.import('../lib/browser/browser').then(() => { +System.import('../../../lib/browser/browser').then(() => { Zone.current.fork({name: 'webworker'}).run(() => { const websocket = new WebSocket('ws://localhost:8001'); websocket.addEventListener('open', () => { diff --git a/karma-build-sauce-mocha.conf.js b/test/karma/ci/build/karma-build-sauce-mocha.conf.js similarity index 60% rename from karma-build-sauce-mocha.conf.js rename to test/karma/ci/build/karma-build-sauce-mocha.conf.js index c35699113..b1573d41c 100644 --- a/karma-build-sauce-mocha.conf.js +++ b/test/karma/ci/build/karma-build-sauce-mocha.conf.js @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -module.exports = function (config) { - require('./karma-dist-mocha.conf.js')(config); - require('./sauce.conf')(config); +module.exports = function(config) { + require('../../common/dist/karma-dist-mocha.conf.js')(config); + require('../sauce.conf')(config); }; diff --git a/karma-build-sauce-selenium3-mocha.conf.js b/test/karma/ci/build/karma-build-sauce-selenium3-mocha.conf.js similarity index 56% rename from karma-build-sauce-selenium3-mocha.conf.js rename to test/karma/ci/build/karma-build-sauce-selenium3-mocha.conf.js index d23462147..eef7b4ea0 100644 --- a/karma-build-sauce-selenium3-mocha.conf.js +++ b/test/karma/ci/build/karma-build-sauce-selenium3-mocha.conf.js @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -module.exports = function (config) { - require('./karma-dist-mocha.conf.js')(config); - require('./sauce-selenium3.conf')(config, ['SL_IE9']); +module.exports = function(config) { + require('../../common/dist/karma-dist-mocha.conf.js')(config); + require('../sauce-selenium3.conf')(config, ['SL_IE9']); }; diff --git a/karma-dist-sauce-jasmine.conf.js b/test/karma/ci/dist/karma-dist-sauce-jasmine.conf.js similarity index 57% rename from karma-dist-sauce-jasmine.conf.js rename to test/karma/ci/dist/karma-dist-sauce-jasmine.conf.js index 44f6be74a..f23f5fc29 100644 --- a/karma-dist-sauce-jasmine.conf.js +++ b/test/karma/ci/dist/karma-dist-sauce-jasmine.conf.js @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -module.exports = function (config) { - require('./karma-dist-jasmine.conf.js')(config); - require('./sauce.conf')(config, ['SL_IOS9']); +module.exports = function(config) { + require('../../common/dist/karma-dist-jasmine.conf.js')(config); + require('../sauce.conf')(config, ['SL_IOS9']); }; diff --git a/test/karma/ci/dist/karma-dist-sauce-jasmine3.conf.js b/test/karma/ci/dist/karma-dist-sauce-jasmine3.conf.js new file mode 100644 index 000000000..643d4bc84 --- /dev/null +++ b/test/karma/ci/dist/karma-dist-sauce-jasmine3.conf.js @@ -0,0 +1,16 @@ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +module.exports = function(config) { + require('../../common/dist/karma-dist-jasmine.conf.js')(config); + require('../sauce.conf')(config, [ + 'SL_IOS9', 'SL_CHROME', 'SL_FIREFOX_54', 'SL_SAFARI8', 'SL_SAFARI9', 'SL_SAFARI10', 'SL_IOS8', + 'SL_IOS9', 'SL_IOS10', 'SL_IE9', 'SL_IE10', 'SL_IE11', 'SL_MSEDGE15', 'SL_ANDROID4.4', + 'SL_ANDROID5.1' + ]) +}; diff --git a/karma-dist-sauce-selenium3-jasmine.conf.js b/test/karma/ci/dist/karma-dist-sauce-selenium3-jasmine.conf.js similarity index 58% rename from karma-dist-sauce-selenium3-jasmine.conf.js rename to test/karma/ci/dist/karma-dist-sauce-selenium3-jasmine.conf.js index d5c65da90..4b1172e04 100644 --- a/karma-dist-sauce-selenium3-jasmine.conf.js +++ b/test/karma/ci/dist/karma-dist-sauce-selenium3-jasmine.conf.js @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -module.exports = function (config) { - require('./karma-dist-jasmine.conf.js')(config); - require('./sauce-selenium3.conf')(config); +module.exports = function(config) { + require('../../common/dist/karma-dist-jasmine.conf.js')(config); + require('../sauce-selenium3.conf')(config); }; diff --git a/sauce-selenium3.conf.js b/test/karma/ci/sauce-selenium3.conf.js similarity index 57% rename from sauce-selenium3.conf.js rename to test/karma/ci/sauce-selenium3.conf.js index 4c4b7322e..a7c7c4645 100644 --- a/sauce-selenium3.conf.js +++ b/test/karma/ci/sauce-selenium3.conf.js @@ -1,16 +1,12 @@ // Sauce configuration with Welenium drivers 3+ -module.exports = function (config) { +module.exports = function(config) { // The WS server is not available with Sauce - config.files.unshift('test/saucelabs.js'); + config.files.unshift('test/env/config/saucelabs.js'); var customLaunchers = { - 'SL_CHROME60': { - base: 'SauceLabs', - browserName: 'Chrome', - platform: 'Windows 10', - version: '60.0' - } + 'SL_CHROME60': + {base: 'SauceLabs', browserName: 'Chrome', platform: 'Windows 10', version: '60.0'} }; config.set({ @@ -22,11 +18,11 @@ module.exports = function (config) { startConnect: false, recordVideo: false, recordScreenshots: false, - options: { - 'selenium-version': '3.5.0', - 'command-timeout': 600, - 'idle-timeout': 600, - 'max-duration': 5400 + options: { + 'selenium-version': '3.5.0', + 'command-timeout': 600, + 'idle-timeout': 600, + 'max-duration': 5400 } }, @@ -38,13 +34,12 @@ module.exports = function (config) { singleRun: true, - plugins: [ - 'karma-*' - ] + plugins: ['karma-*'] }); if (process.env.TRAVIS) { - config.sauceLabs.build = 'TRAVIS #' + process.env.TRAVIS_BUILD_NUMBER + ' (' + process.env.TRAVIS_BUILD_ID + ')'; + config.sauceLabs.build = + 'TRAVIS #' + process.env.TRAVIS_BUILD_NUMBER + ' (' + process.env.TRAVIS_BUILD_ID + ')'; config.sauceLabs.tunnelIdentifier = process.env.TRAVIS_JOB_NUMBER; process.env.SAUCE_ACCESS_KEY = process.env.SAUCE_ACCESS_KEY.split('').reverse().join(''); diff --git a/sauce.conf.js b/test/karma/ci/sauce.conf.js similarity index 98% rename from sauce.conf.js rename to test/karma/ci/sauce.conf.js index 1aac560bd..749b0da04 100644 --- a/sauce.conf.js +++ b/test/karma/ci/sauce.conf.js @@ -2,7 +2,7 @@ module.exports = function(config, ignoredLaunchers) { // The WS server is not available with Sauce - config.files.unshift('test/saucelabs.js'); + config.files.unshift('test/env/config/saucelabs.js'); var basicLaunchers = { 'SL_CHROME': {base: 'SauceLabs', browserName: 'chrome', version: '48'}, diff --git a/karma-build-jasmine-phantomjs.conf.js b/test/karma/common/build/karma-build-jasmine-phantomjs.conf.js similarity index 86% rename from karma-build-jasmine-phantomjs.conf.js rename to test/karma/common/build/karma-build-jasmine-phantomjs.conf.js index 91b0d0c31..54989858d 100644 --- a/karma-build-jasmine-phantomjs.conf.js +++ b/test/karma/common/build/karma-build-jasmine-phantomjs.conf.js @@ -1,5 +1,5 @@ -module.exports = function (config) { +module.exports = function(config) { require('./karma-build.conf.js')(config); config.plugins.push(require('karma-jasmine')); diff --git a/karma-build-jasmine.conf.js b/test/karma/common/build/karma-build-jasmine.conf.js similarity index 77% rename from karma-build-jasmine.conf.js rename to test/karma/common/build/karma-build-jasmine.conf.js index 29747ca33..7c038f67c 100644 --- a/karma-build-jasmine.conf.js +++ b/test/karma/common/build/karma-build-jasmine.conf.js @@ -1,5 +1,4 @@ - -module.exports = function (config) { +module.exports = function(config) { require('./karma-build.conf.js')(config); config.plugins.push(require('karma-jasmine')); diff --git a/karma-build-mocha-jasmine-bridge.conf.js b/test/karma/common/build/karma-build-mocha-jasmine-bridge.conf.js similarity index 60% rename from karma-build-mocha-jasmine-bridge.conf.js rename to test/karma/common/build/karma-build-mocha-jasmine-bridge.conf.js index 14a51c9c1..9fd3a802d 100644 --- a/karma-build-mocha-jasmine-bridge.conf.js +++ b/test/karma/common/build/karma-build-mocha-jasmine-bridge.conf.js @@ -1,13 +1,13 @@ module.exports = function(config) { - require('./karma-base.conf.js')(config); - config.files.push('build/test/mocha/mocha-browser-karma.js'); - config.files.push('build/test/wtf_mock.js'); - config.files.push('build/test/test_fake_polyfill.js'); + require('../karma-base.conf.js')(config); + config.files.push('build/test/spec/mocha/mocha-browser-karma.js'); + config.files.push('build/test/env/polyfills/wtf_mock.js'); + config.files.push('build/test/env/polyfills/test_fake_polyfill.js'); config.files.push('build/lib/zone.js'); config.files.push('build/lib/common/promise.js'); config.files.push('build/lib/common/error-rewrite.js'); - config.files.push('build/test/main.js'); + config.files.push('build/test/env/browser/main.js'); config.plugins.push(require('karma-mocha')); config.frameworks.push('mocha'); diff --git a/karma-build-mocha.conf.js b/test/karma/common/build/karma-build-mocha.conf.js similarity index 100% rename from karma-build-mocha.conf.js rename to test/karma/common/build/karma-build-mocha.conf.js diff --git a/karma-build.conf.js b/test/karma/common/build/karma-build.conf.js similarity index 57% rename from karma-build.conf.js rename to test/karma/common/build/karma-build.conf.js index 87c87a5ea..d25337e61 100644 --- a/karma-build.conf.js +++ b/test/karma/common/build/karma-build.conf.js @@ -6,12 +6,12 @@ * found in the LICENSE file at https://angular.io/license */ -module.exports = function (config) { - require('./karma-base.conf.js')(config); - config.files.push('build/test/wtf_mock.js'); - config.files.push('build/test/test_fake_polyfill.js'); +module.exports = function(config) { + require('../karma-base.conf.js')(config); + config.files.push('build/test/env/polyfills/wtf_mock.js'); + config.files.push('build/test/env/polyfills/test_fake_polyfill.js'); config.files.push('build/lib/zone.js'); config.files.push('build/lib/common/promise.js'); config.files.push('build/lib/common/error-rewrite.js'); - config.files.push('build/test/main.js'); + config.files.push('build/test/env/browser/main.js'); }; diff --git a/karma-dist-jasmine.conf.js b/test/karma/common/dist/karma-dist-jasmine.conf.js similarity index 78% rename from karma-dist-jasmine.conf.js rename to test/karma/common/dist/karma-dist-jasmine.conf.js index 9d6cb428d..32627d46e 100644 --- a/karma-dist-jasmine.conf.js +++ b/test/karma/common/dist/karma-dist-jasmine.conf.js @@ -1,5 +1,5 @@ -module.exports = function (config) { +module.exports = function(config) { require('./karma-dist.conf.js')(config); config.plugins.push(require('karma-jasmine')); diff --git a/karma-dist-mocha.conf.js b/test/karma/common/dist/karma-dist-mocha.conf.js similarity index 100% rename from karma-dist-mocha.conf.js rename to test/karma/common/dist/karma-dist-mocha.conf.js diff --git a/karma-dist.conf.js b/test/karma/common/dist/karma-dist.conf.js similarity index 68% rename from karma-dist.conf.js rename to test/karma/common/dist/karma-dist.conf.js index 9d40dee62..74454bc1e 100644 --- a/karma-dist.conf.js +++ b/test/karma/common/dist/karma-dist.conf.js @@ -7,15 +7,14 @@ */ module.exports = function(config) { - require('./karma-base.conf.js')(config); - config.files.push('build/test/wtf_mock.js'); - config.files.push('build/test/test_fake_polyfill.js'); - config.files.push('build/test/custom_error.js'); + require('../karma-base.conf.js')(config); + config.files.push('build/test/env/polyfills/wtf_mock.js'); + config.files.push('build/test/env/polyfills/test_fake_polyfill.js'); config.files.push('dist/zone.js'); config.files.push('dist/zone-patch-user-media.js'); config.files.push('dist/zone-patch-resize-observer.js'); config.files.push('dist/zone-testing.js'); config.files.push('dist/task-tracking.js'); config.files.push('dist/wtf.js'); - config.files.push('build/test/main.js'); + config.files.push('build/test/env/browser/main.js'); }; diff --git a/karma-base.conf.js b/test/karma/common/karma-base.conf.js similarity index 68% rename from karma-base.conf.js rename to test/karma/common/karma-base.conf.js index 0778ebe2e..f51a1947e 100644 --- a/karma-base.conf.js +++ b/test/karma/common/karma-base.conf.js @@ -6,45 +6,39 @@ * found in the LICENSE file at https://angular.io/license */ -module.exports = function (config) { +module.exports = function(config) { config.set({ - basePath: '', + basePath: '../../../../', files: [ - 'node_modules/systemjs/dist/system-polyfills.js', - 'node_modules/systemjs/dist/system.src.js', + 'node_modules/systemjs/dist/system-polyfills.js', 'node_modules/systemjs/dist/system.src.js', 'node_modules/whatwg-fetch/fetch.js', - {pattern: 'node_modules/rxjs/**/**/*.js', included: false, watched: false }, - {pattern: 'node_modules/rxjs/**/**/*.js.map', included: false, watched: false }, - {pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false }, - {pattern: 'node_modules/es6-promise/**/*.js', included: false, watched: false }, - {pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false }, + {pattern: 'node_modules/rxjs/**/**/*.js', included: false, watched: false}, + {pattern: 'node_modules/rxjs/**/**/*.js.map', included: false, watched: false}, + {pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false}, + {pattern: 'node_modules/es6-promise/**/*.js', included: false, watched: false}, + {pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false}, {pattern: 'test/assets/**/*.*', watched: true, served: true, included: false}, {pattern: 'build/**/*.js.map', watched: true, served: true, included: false}, {pattern: 'build/**/*.js', watched: true, served: true, included: false} ], plugins: [ - require('karma-chrome-launcher'), - require('karma-firefox-launcher'), + require('karma-chrome-launcher'), require('karma-firefox-launcher'), require('karma-sourcemap-loader') ], - preprocessors: { - '**/*.js': ['sourcemap'] - }, + preprocessors: {'**/*.js': ['sourcemap']}, - exclude: [ - 'test/microtasks.spec.ts' - ], + exclude: ['test/spec/common/microtasks.spec.ts'], reporters: ['progress'], - //port: 9876, + // port: 9876, colors: true, logLevel: config.LOG_INFO, - browsers: ['Firefox'], + browsers: ['Chrome'], captureTimeout: 60000, diff --git a/test/node_bluebird_entry_point.ts b/test/node_bluebird_entry_point.ts deleted file mode 100644 index 8c5a86f65..000000000 --- a/test/node_bluebird_entry_point.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -// Must be loaded before zone loads, so that zone can detect WTF. -import './wtf_mock'; -import './test_fake_polyfill'; - -// Setup tests for Zone without microtask support -import '../lib/zone'; -import '../lib/common/promise'; -import '../lib/common/to-string'; -import '../lib/node/node'; -import '../lib/zone-spec/async-test'; -import '../lib/zone-spec/fake-async-test'; -import '../lib/zone-spec/long-stack-trace'; -import '../lib/zone-spec/proxy'; -import '../lib/zone-spec/sync-test'; -import '../lib/zone-spec/task-tracking'; -import '../lib/zone-spec/wtf'; -import '../lib/rxjs/rxjs'; - -import '../lib/testing/promise-testing'; -// Setup test environment -import './test-env-setup-jasmine'; - -// List all tests here: -import './extra/bluebird.spec'; \ No newline at end of file diff --git a/test/node_tests.ts b/test/node_tests.ts deleted file mode 100644 index 0fcc9b6aa..000000000 --- a/test/node_tests.ts +++ /dev/null @@ -1,15 +0,0 @@ -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import './node/events.spec'; -import './node/fs.spec'; -import './node/process.spec'; -import './node/Error.spec'; -import './node/crypto.spec'; -import './node/http.spec'; -import './node/console.spec'; diff --git a/test/rxjs/rxjs.fromEvent.spec.ts b/test/rxjs/rxjs.fromEvent.spec.ts deleted file mode 100644 index 6020ee795..000000000 --- a/test/rxjs/rxjs.fromEvent.spec.ts +++ /dev/null @@ -1,121 +0,0 @@ -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import * as Rx from 'rxjs/Rx'; - -import {isBrowser} from '../../lib/common/utils'; -import {ifEnvSupports} from '../test-util'; - -function isEventTarget() { - return isBrowser; -} - -(isEventTarget as any).message = 'EventTargetTest'; - -describe('Observable.fromEvent', () => { - let log: string[]; - const constructorZone1: Zone = Zone.current.fork({ - name: 'Constructor Zone1' - }); - const subscriptionZone: Zone = Zone.current.fork({ - name: 'Subscription Zone' - }); - const triggerZone: Zone = Zone.current.fork({ name: 'Trigger Zone' }); - let observable1: any; - - beforeEach(() => { - log = []; - }); - - it( - 'fromEvent EventTarget func callback should run in the correct zone', - ifEnvSupports(isEventTarget, () => { - observable1 = constructorZone1.run(() => { - return Rx.Observable.fromEvent(document, 'click'); - }); - - const clickEvent = document.createEvent('Event'); - clickEvent.initEvent('click', true, true); - - subscriptionZone.run(() => { - observable1.subscribe( - (result: any) => { - expect(Zone.current.name).toEqual(subscriptionZone.name); - log.push(result); - }, - () => { - fail('should not call error'); - }, - () => { - expect(Zone.current.name).toEqual(subscriptionZone.name); - log.push('completed'); - } - ); - }); - - triggerZone.run(() => { - document.dispatchEvent(clickEvent); - }); - - expect(log).toEqual([clickEvent]); - }) - ); - - it( - 'fromEventPattern EventTarget func callback should run in the correct zone', - ifEnvSupports(isEventTarget, () => { - const button = document.createElement('button'); - document.body.appendChild(button); - observable1 = constructorZone1.run(() => { - return Rx.Observable.fromEventPattern( - (handler: any) => { - expect(Zone.current.name).toEqual(constructorZone1.name); - button.addEventListener('click', handler); - log.push('addListener'); - }, - (handler: any) => { - expect(Zone.current.name).toEqual(constructorZone1.name); - button.removeEventListener('click', handler); - document.body.removeChild(button); - log.push('removeListener'); - } - ); - }); - - const clickEvent = document.createEvent('Event'); - clickEvent.initEvent('click', false, false); - - const subscriper: any = subscriptionZone.run(() => { - return observable1.subscribe( - (result: any) => { - expect(Zone.current.name).toEqual(subscriptionZone.name); - log.push(result); - }, - () => { - fail('should not call error'); - }, - () => { - expect(Zone.current.name).toEqual(subscriptionZone.name); - log.push('completed'); - } - ); - }); - - triggerZone.run(() => { - button.dispatchEvent(clickEvent); - subscriper.complete(); - }); - expect(log).toEqual([ - 'addListener', - clickEvent, - 'completed', - 'removeListener' - ]); - }) - ); -}); diff --git a/test/browser/FileReader.spec.ts b/test/spec/browser/FileReader.spec.ts similarity index 100% rename from test/browser/FileReader.spec.ts rename to test/spec/browser/FileReader.spec.ts diff --git a/test/browser/HTMLImports.spec.ts b/test/spec/browser/HTMLImports.spec.ts similarity index 100% rename from test/browser/HTMLImports.spec.ts rename to test/spec/browser/HTMLImports.spec.ts diff --git a/test/browser/MediaQuery.spec.ts b/test/spec/browser/MediaQuery.spec.ts similarity index 89% rename from test/browser/MediaQuery.spec.ts rename to test/spec/browser/MediaQuery.spec.ts index 465d23102..a92458c24 100644 --- a/test/browser/MediaQuery.spec.ts +++ b/test/spec/browser/MediaQuery.spec.ts @@ -6,9 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ -import '../../lib/browser/webapis-media-query'; +import '../../../lib/browser/webapis-media-query'; -import {zoneSymbol} from '../../lib/common/utils'; +import {zoneSymbol} from '../../../lib/common/utils'; import {ifEnvSupports} from '../test-util'; declare const global: any; diff --git a/test/browser/MutationObserver.spec.ts b/test/spec/browser/MutationObserver.spec.ts similarity index 100% rename from test/browser/MutationObserver.spec.ts rename to test/spec/browser/MutationObserver.spec.ts diff --git a/test/browser/Notification.spec.ts b/test/spec/browser/Notification.spec.ts similarity index 89% rename from test/browser/Notification.spec.ts rename to test/spec/browser/Notification.spec.ts index 5c23fccab..70e2b35d6 100644 --- a/test/browser/Notification.spec.ts +++ b/test/spec/browser/Notification.spec.ts @@ -6,9 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ -import '../../lib/browser/webapis-notification'; +import '../../../lib/browser/webapis-notification'; -import {zoneSymbol} from '../../lib/common/utils'; +import {zoneSymbol} from '../../../lib/common/utils'; import {ifEnvSupports} from '../test-util'; declare const window: any; diff --git a/test/browser/WebSocket.spec.ts b/test/spec/browser/WebSocket.spec.ts similarity index 95% rename from test/browser/WebSocket.spec.ts rename to test/spec/browser/WebSocket.spec.ts index 1ee4b39d8..32aeb12d4 100644 --- a/test/browser/WebSocket.spec.ts +++ b/test/spec/browser/WebSocket.spec.ts @@ -28,7 +28,7 @@ if (!window['saucelabs']) { socket.addEventListener('error', function() { fail( 'Can\'t establish socket to ' + TEST_SERVER_URL + - '! do you have test/ws-server.js running?'); + '! do you have test/env/websocket/ws-server.js running?'); done(); }); }, TIMEOUT); @@ -42,7 +42,7 @@ if (!window['saucelabs']) { it('should be patched in a Web Worker', done => { - const worker = new Worker('/base/build/test/ws-webworker-context.js'); + const worker = new Worker('/base/build/test/env/websocket/ws-webworker-context.js'); worker.onmessage = (e: MessageEvent) => { expect(e.data).toBe('pass'); done(); diff --git a/test/browser/Worker.spec.ts b/test/spec/browser/Worker.spec.ts similarity index 95% rename from test/browser/Worker.spec.ts rename to test/spec/browser/Worker.spec.ts index fcaa386d0..75193d45f 100644 --- a/test/browser/Worker.spec.ts +++ b/test/spec/browser/Worker.spec.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {zoneSymbol} from '../../lib/common/utils'; +import {zoneSymbol} from '../../../lib/common/utils'; import {asyncTest, ifEnvSupports} from '../test-util'; function workerSupport() { diff --git a/test/browser/XMLHttpRequest.spec.ts b/test/spec/browser/XMLHttpRequest.spec.ts similarity index 100% rename from test/browser/XMLHttpRequest.spec.ts rename to test/spec/browser/XMLHttpRequest.spec.ts diff --git a/test/browser/browser.spec.ts b/test/spec/browser/browser.spec.ts similarity index 99% rename from test/browser/browser.spec.ts rename to test/spec/browser/browser.spec.ts index 9b013d70c..72f462f69 100644 --- a/test/browser/browser.spec.ts +++ b/test/spec/browser/browser.spec.ts @@ -6,9 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ -import {patchFilteredProperties} from '../../lib/browser/property-descriptor'; -import {patchEventTarget} from '../../lib/common/events'; -import {isBrowser, isIEOrEdge, isMix, zoneSymbol} from '../../lib/common/utils'; +import {patchFilteredProperties} from '../../../lib/browser/property-descriptor'; +import {patchEventTarget} from '../../../lib/common/events'; +import {isBrowser, isIEOrEdge, isMix, zoneSymbol} from '../../../lib/common/utils'; import {getIEVersion, ifEnvSupports, ifEnvSupportsWithDone, isEdge} from '../test-util'; import Spy = jasmine.Spy; @@ -135,7 +135,7 @@ describe('Zone', function() { ignoredProperties.filter(ignoreProp => ignoreProp === prop).length > 0) { continue; } - if (prop.substr(0, 2) === 'on' && prop.length > 2) { + if (prop.substr(0, 2) === 'on' && prop.length > 2 && prop !== 'only') { target[prop] = noop; if (!target[Zone.__symbol__('ON_PROPERTY' + prop.substr(2))]) { console.log('onProp is null:', prop); diff --git a/test/browser/define-property.spec.ts b/test/spec/browser/define-property.spec.ts similarity index 100% rename from test/browser/define-property.spec.ts rename to test/spec/browser/define-property.spec.ts diff --git a/test/browser/element.spec.ts b/test/spec/browser/element.spec.ts similarity index 100% rename from test/browser/element.spec.ts rename to test/spec/browser/element.spec.ts diff --git a/test/browser/geolocation.spec.manual.ts b/test/spec/browser/geolocation.spec.manual.ts similarity index 100% rename from test/browser/geolocation.spec.manual.ts rename to test/spec/browser/geolocation.spec.manual.ts diff --git a/test/browser/registerElement.spec.ts b/test/spec/browser/registerElement.spec.ts similarity index 100% rename from test/browser/registerElement.spec.ts rename to test/spec/browser/registerElement.spec.ts diff --git a/test/browser/requestAnimationFrame.spec.ts b/test/spec/browser/requestAnimationFrame.spec.ts similarity index 100% rename from test/browser/requestAnimationFrame.spec.ts rename to test/spec/browser/requestAnimationFrame.spec.ts diff --git a/test/closure/zone.closure.ts b/test/spec/closure/zone.closure.ts similarity index 100% rename from test/closure/zone.closure.ts rename to test/spec/closure/zone.closure.ts diff --git a/test/common/Error.spec.ts b/test/spec/common/Error.spec.ts similarity index 100% rename from test/common/Error.spec.ts rename to test/spec/common/Error.spec.ts diff --git a/test/common/Promise.spec.ts b/test/spec/common/Promise.spec.ts similarity index 90% rename from test/common/Promise.spec.ts rename to test/spec/common/Promise.spec.ts index d6a803b72..c21c12475 100644 --- a/test/common/Promise.spec.ts +++ b/test/spec/common/Promise.spec.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {isNode, zoneSymbol} from '../../lib/common/utils'; +import {isNode, zoneSymbol} from '../../../lib/common/utils'; import {ifEnvSupports} from '../test-util'; declare const global: any; @@ -51,11 +51,12 @@ describe( pZone = Zone.current.fork({ name: 'promise-zone', - onScheduleTask: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - task: MicroTask): any => { - log.push('scheduleTask'); - parentZoneDelegate.scheduleTask(targetZone, task); - } + onScheduleTask: + (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, + task: MicroTask): any => { + log.push('scheduleTask'); + parentZoneDelegate.scheduleTask(targetZone, task); + } }); queueZone = Zone.current.fork(new MicroTaskQueueZoneSpec()); @@ -352,11 +353,11 @@ describe( .fork({ name: 'promise-error', onHandleError: (delegate: ZoneDelegate, current: Zone, target: Zone, error: any): - boolean => { - promiseError = error; - delegate.handleError(target, error); - return false; - } + boolean => { + promiseError = error; + delegate.handleError(target, error); + return false; + } }) .run(() => { zone = Zone.current; @@ -391,11 +392,11 @@ describe( .fork({ name: 'promise-error', onHandleError: (delegate: ZoneDelegate, current: Zone, target: Zone, error: any): - boolean => { - promiseError = error; - delegate.handleError(target, error); - return false; - } + boolean => { + promiseError = error; + delegate.handleError(target, error); + return false; + } }) .run(() => { zone = Zone.current; @@ -462,27 +463,27 @@ describe( }); }); - it('should resolve generators', ifEnvSupports( - () => { - return isNode; - }, - () => { - const generators: any = function*() { - yield Promise.resolve(1); - yield Promise.resolve(2); - return; - }; - queueZone.run(() => { - let value = null; - Promise.all(generators()).then(val => { - value = val; - }); - // expect(Zone.current.get('queue').length).toEqual(2); - flushMicrotasks(); - expect(value).toEqual([1, 2]); - }); - - })); + it('should resolve generators', + ifEnvSupports( + () => { + return isNode; + }, + () => { + const generators: any = function*() { + yield Promise.resolve(1); + yield Promise.resolve(2); + return; + }; + queueZone.run(() => { + let value = null; + Promise.all(generators()).then(val => { + value = val; + }); + // expect(Zone.current.get('queue').length).toEqual(2); + flushMicrotasks(); + expect(value).toEqual([1, 2]); + }); + })); }); }); @@ -540,7 +541,7 @@ describe( expect(result).toBe('foo'); done && done(); }); - } + } it('should resolve if the Promise subclass resolves', jasmine ? function(done) { testPromiseSubClass(done); @@ -619,6 +620,5 @@ describe( }); }); }); - })); })); diff --git a/test/common/microtasks.spec.ts b/test/spec/common/microtasks.spec.ts similarity index 100% rename from test/common/microtasks.spec.ts rename to test/spec/common/microtasks.spec.ts diff --git a/test/common/setInterval.spec.ts b/test/spec/common/setInterval.spec.ts similarity index 98% rename from test/common/setInterval.spec.ts rename to test/spec/common/setInterval.spec.ts index 42aaac7b0..e059be8ea 100644 --- a/test/common/setInterval.spec.ts +++ b/test/spec/common/setInterval.spec.ts @@ -7,11 +7,10 @@ */ 'use strict'; -import {isNode, zoneSymbol} from '../../lib/common/utils'; +import {isNode, zoneSymbol} from '../../../lib/common/utils'; declare const global: any; describe('setInterval', function() { - it('should work with setInterval', function(done) { let cancelId: any; const testZone = Zone.current.fork((Zone as any)['wtfZoneSpec']).fork({name: 'TestZone'}); @@ -86,5 +85,4 @@ describe('setInterval', function() { }, 300); }); }); - }); diff --git a/test/common/setTimeout.spec.ts b/test/spec/common/setTimeout.spec.ts similarity index 98% rename from test/common/setTimeout.spec.ts rename to test/spec/common/setTimeout.spec.ts index c71ab4d5f..f849c2a01 100644 --- a/test/common/setTimeout.spec.ts +++ b/test/spec/common/setTimeout.spec.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {isNode, zoneSymbol} from '../../lib/common/utils'; +import {isNode, zoneSymbol} from '../../../lib/common/utils'; declare const global: any; describe('setTimeout', function() { @@ -119,5 +119,4 @@ describe('setTimeout', function() { clearTimeout(null); clearTimeout({}); }); - }); diff --git a/test/common/task.spec.ts b/test/spec/common/task.spec.ts similarity index 100% rename from test/common/task.spec.ts rename to test/spec/common/task.spec.ts diff --git a/test/common/toString.spec.ts b/test/spec/common/toString.spec.ts similarity index 94% rename from test/common/toString.spec.ts rename to test/spec/common/toString.spec.ts index 1eb33c839..2ec0d56e6 100644 --- a/test/common/toString.spec.ts +++ b/test/spec/common/toString.spec.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {zoneSymbol} from '../../lib/common/utils'; +import {zoneSymbol} from '../../../lib/common/utils'; import {ifEnvSupports} from '../test-util'; const g: any = @@ -37,7 +37,8 @@ describe('global function patch', () => { }); it('Function toString should look like native', () => { - expect(Function.prototype.toString.call(Function.prototype.toString)).toContain('[native code]'); + expect(Function.prototype.toString.call(Function.prototype.toString)) + .toContain('[native code]'); }); it('EventTarget addEventListener should look like native', ifEnvSupports('HTMLElement', () => { diff --git a/test/common/util.spec.ts b/test/spec/common/util.spec.ts similarity index 99% rename from test/common/util.spec.ts rename to test/spec/common/util.spec.ts index b6b122d10..669bd68ed 100644 --- a/test/common/util.spec.ts +++ b/test/spec/common/util.spec.ts @@ -6,10 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ -import {patchMethod, patchProperty, patchPrototype, zoneSymbol} from '../../lib/common/utils'; +import {patchMethod, patchProperty, patchPrototype, zoneSymbol} from '../../../lib/common/utils'; describe('utils', function() { - describe('patchMethod', () => { it('should patch target where the method is defined', () => { let args; diff --git a/test/common/zone.spec.ts b/test/spec/common/zone.spec.ts similarity index 97% rename from test/common/zone.spec.ts rename to test/spec/common/zone.spec.ts index f969df913..9bd5e9437 100644 --- a/test/common/zone.spec.ts +++ b/test/spec/common/zone.spec.ts @@ -5,7 +5,7 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ -import {zoneSymbol} from '../../lib/common/utils'; +import {zoneSymbol} from '../../../lib/common/utils'; describe('Zone', function() { const rootZone = Zone.current; @@ -15,7 +15,6 @@ describe('Zone', function() { }); describe('hooks', function() { - it('should throw if onError is not defined', function() { expect(function() { Zone.current.run(throwError); @@ -126,10 +125,10 @@ describe('Zone', function() { const zone: Zone = Zone.current.fork({ name: 'parent', onHasTask: (delegate: ZoneDelegate, current: Zone, target: Zone, hasTaskState: HasTaskState): - void => { - (hasTaskState as any)['zone'] = target.name; - log.push(hasTaskState); - }, + void => { + (hasTaskState as any)['zone'] = target.name; + log.push(hasTaskState); + }, onScheduleTask: (delegate: ZoneDelegate, current: Zone, target: Zone, task: Task) => { // Do nothing to prevent tasks from being run on VM turn; // Tests run task explicitly. @@ -394,10 +393,11 @@ describe('Zone', function() { const spy = jasmine.createSpy('error'); const hasTaskZone = Zone.current.fork({ name: 'hasTask', - onHasTask: (delegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - hasTasState: HasTaskState) => { - throw new Error('onHasTask Error'); - }, + onHasTask: + (delegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, + hasTasState: HasTaskState) => { + throw new Error('onHasTask Error'); + }, onHandleError: (delegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, error: Error) => { spy(error.message); diff --git a/test/extra/bluebird.spec.ts b/test/spec/extra/bluebird.spec.ts similarity index 91% rename from test/extra/bluebird.spec.ts rename to test/spec/extra/bluebird.spec.ts index b86ceac15..fb1080ca6 100644 --- a/test/extra/bluebird.spec.ts +++ b/test/spec/extra/bluebird.spec.ts @@ -15,7 +15,7 @@ describe('bluebird promise', () => { beforeAll(() => { BluebirdPromise = require('bluebird'); // import bluebird patch - require('../../lib/extra/bluebird'); + require('../../../lib/extra/bluebird'); const patchBluebird = (Zone as any)[(Zone as any).__symbol__('bluebird')]; patchBluebird(BluebirdPromise); }); @@ -76,7 +76,8 @@ describe('bluebird promise', () => { .spread((r1: string, r2: string) => { expect(r1).toEqual('test1'); expect(r2).toEqual('test2'); - expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length) + .toBe(1); expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); done(); @@ -112,7 +113,8 @@ describe('bluebird promise', () => { }) .then(() => { expect(Zone.current.name).toEqual('bluebird'); - expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length) + .toBe(1); expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); done(); }); @@ -126,7 +128,8 @@ describe('bluebird promise', () => { throw new Error('promise error'); }) .catch((err: Error) => { - expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length) + .toBe(1); expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); expect(err.message).toEqual('promise error'); @@ -142,7 +145,8 @@ describe('bluebird promise', () => { return 'test'; })() .then((result: string) => { - expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length) + .toBe(1); expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); expect(result).toEqual('test'); @@ -181,7 +185,8 @@ describe('bluebird promise', () => { .then((r: string[]) => { expect(r[0]).toEqual('test1'); expect(r[1]).toEqual('test2'); - expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length) + .toBe(1); expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); done(); @@ -196,7 +201,8 @@ describe('bluebird promise', () => { .then((r: any) => { expect(r.test1).toEqual('test1'); expect(r.test2).toEqual('test2'); - expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length) + .toBe(1); expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); done(); @@ -209,7 +215,8 @@ describe('bluebird promise', () => { BluebirdPromise.any([BluebirdPromise.resolve('test1'), BluebirdPromise.resolve('test2')]) .then((r: any) => { expect(r).toEqual('test1'); - expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length) + .toBe(1); expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); done(); @@ -223,7 +230,8 @@ describe('bluebird promise', () => { .then((r: any) => { expect(r.length).toBe(1); expect(r[0]).toEqual('test1'); - expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length) + .toBe(1); expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); done(); @@ -243,7 +251,8 @@ describe('bluebird promise', () => { expect(r.length).toBe(2); expect(r[0]).toEqual('test1'); expect(r[1]).toEqual('test2'); - expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length) + .toBe(1); expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); done(); @@ -282,7 +291,8 @@ describe('bluebird promise', () => { }) .then((r: number[]) => { expect(r[0]).toBe(2); - expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length) + .toBe(1); expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); done(); @@ -293,12 +303,14 @@ describe('bluebird promise', () => { it('bluebird promise each method should be in zone', (done) => { zone.run(() => { const arr = [1, 2, 3]; - BluebirdPromise.each( - BluebirdPromise.map(arr, (item: number) => BluebirdPromise.resolve(item)), - (r: number[], idx: number) => { - expect(r[idx] === arr[idx]); - expect(Zone.current.name).toEqual('bluebird'); - }).then((r: any) => { + BluebirdPromise + .each( + BluebirdPromise.map(arr, (item: number) => BluebirdPromise.resolve(item)), + (r: number[], idx: number) => { + expect(r[idx] === arr[idx]); + expect(Zone.current.name).toEqual('bluebird'); + }) + .then((r: any) => { expect(log.filter(item => item === 'schedule bluebird task Promise.then').length) .toBeTruthy(); expect(log.filter(item => item === 'invoke bluebird task Promise.then').length) @@ -312,19 +324,22 @@ describe('bluebird promise', () => { it('bluebird promise mapSeries method should be in zone', (done) => { zone.run(() => { const arr = [1, 2, 3]; - BluebirdPromise.mapSeries( - BluebirdPromise.map(arr, (item: number) => BluebirdPromise.resolve(item)), - (r: number[], idx: number) => { - expect(r[idx] === arr[idx]); - expect(Zone.current.name).toEqual('bluebird'); - }).then((r: any) => { + BluebirdPromise + .mapSeries( + BluebirdPromise.map(arr, (item: number) => BluebirdPromise.resolve(item)), + (r: number[], idx: number) => { + expect(r[idx] === arr[idx]); + expect(Zone.current.name).toEqual('bluebird'); + }) + .then((r: any) => { expect(log.filter(item => item === 'schedule bluebird task Promise.then').length) .toBeTruthy(); expect(log.filter(item => item === 'invoke bluebird task Promise.then').length) .toBeTruthy(); expect(Zone.current.name).toEqual('bluebird'); done(); - });; + }); + ; }); }); @@ -333,7 +348,8 @@ describe('bluebird promise', () => { BluebirdPromise.race([BluebirdPromise.resolve('test1'), BluebirdPromise.resolve('test2')]) .then((r: string) => { expect(r).toEqual('test1'); - expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length) + .toBe(1); expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); done(); @@ -362,8 +378,10 @@ describe('bluebird promise', () => { expect(Zone.current.name).toEqual('bluebird'); expect(p.leakObj).toBe(null); // using will generate several promise inside bluebird - expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBeTruthy(); - expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBeTruthy(); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length) + .toBeTruthy(); + expect(log.filter(item => item === 'invoke bluebird task Promise.then').length) + .toBeTruthy(); done(); }); }); @@ -410,7 +428,8 @@ describe('bluebird promise', () => { expect(r[0]).toBe('test1'); expect(r[1]).toBe('test2'); // using will generate several promise inside - expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length) + .toBe(1); expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); done(); }); @@ -468,7 +487,8 @@ describe('bluebird promise', () => { .then((r: string) => { expect(Zone.current.name).toEqual('bluebird'); expect(r).toBe('test'); - expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length) + .toBe(1); expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); done(); }); @@ -483,8 +503,8 @@ describe('bluebird promise', () => { }, 0); }); p.tap(() => { - expect(Zone.current.name).toEqual('bluebird'); - }).then(() => { + expect(Zone.current.name).toEqual('bluebird'); + }).then(() => { expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); @@ -508,7 +528,8 @@ describe('bluebird promise', () => { }) .then((r: string) => { expect(r).toEqual('test1'); - expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length) + .toBe(1); expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); done(); @@ -530,7 +551,7 @@ describe('bluebird promise', () => { it('bluebird promise return method should be in zone', (done) => { zone.run(() => { - BluebirdPromise.resolve().return ('test1').then((r: string) => { + BluebirdPromise.resolve().return('test1').then((r: string) => { expect(r).toEqual('test1'); expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); @@ -596,9 +617,7 @@ describe('bluebird promise', () => { }); it('bluebird should be able to run into different zone', (done: Function) => { - Zone.current.fork({ - name: 'zone_A' - }).run(() => { + Zone.current.fork({name: 'zone_A'}).run(() => { new BluebirdPromise((resolve: any, reject: any) => { expect(Zone.current.name).toEqual('zone_A'); resolve(1); @@ -606,10 +625,8 @@ describe('bluebird promise', () => { expect(Zone.current.name).toEqual('zone_A'); }); }); - - Zone.current.fork({ - name: 'zone_B' - }).run(() => { + + Zone.current.fork({name: 'zone_B'}).run(() => { new BluebirdPromise((resolve: any, reject: any) => { expect(Zone.current.name).toEqual('zone_B'); resolve(2); diff --git a/test/extra/cordova.spec.ts b/test/spec/extra/cordova.spec.ts similarity index 100% rename from test/extra/cordova.spec.ts rename to test/spec/extra/cordova.spec.ts diff --git a/test/jasmine-patch.spec.ts b/test/spec/jasmine/jasmine-patch.spec.ts similarity index 80% rename from test/jasmine-patch.spec.ts rename to test/spec/jasmine/jasmine-patch.spec.ts index c7fc9be7d..3df23f3fc 100644 --- a/test/jasmine-patch.spec.ts +++ b/test/spec/jasmine/jasmine-patch.spec.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {ifEnvSupports} from './test-util'; +import {ifEnvSupports} from '../test-util'; function supportJasmineSpec() { return jasmine && (jasmine as any)['Spec']; @@ -22,6 +22,8 @@ ifEnvSupports(supportJasmineSpec, () => { describe('jasmine', () => { let throwOnAsync = false; + let beforeAllZone: Zone = null; + let beforeAllCalledCount = 0; let beforeEachZone: Zone = null; let itZone: Zone = null; const syncZone = Zone.current; @@ -31,6 +33,18 @@ ifEnvSupports(supportJasmineSpec, () => { throwOnAsync = true; } + beforeAll(() => { + beforeAllZone = Zone.current; + beforeAllCalledCount ++; + }); + + afterAll(() => { + let zone = Zone.current; + expect(zone.name).toEqual('ProxyZone'); + expect(beforeAllZone.name).toEqual(zone.name); + expect(beforeAllCalledCount).toBe(1); + }); + beforeEach(() => beforeEachZone = Zone.current); it('should throw on async in describe', () => { diff --git a/test/mocha/jasmine-bridge.spec.ts b/test/spec/mocha/jasmine-bridge.spec.ts similarity index 99% rename from test/mocha/jasmine-bridge.spec.ts rename to test/spec/mocha/jasmine-bridge.spec.ts index 53c85d84d..99f2b43df 100644 --- a/test/mocha/jasmine-bridge.spec.ts +++ b/test/spec/mocha/jasmine-bridge.spec.ts @@ -602,7 +602,7 @@ describe('A spy, when configured to throw an error', function() { it('throws the value', function() { expect(function() { - foo.setBar(123) + foo.setBar(123); }).toThrowError('quux'); }); }); diff --git a/test/mocha/mocha-browser-karma.ts b/test/spec/mocha/mocha-browser-karma.ts similarity index 100% rename from test/mocha/mocha-browser-karma.ts rename to test/spec/mocha/mocha-browser-karma.ts diff --git a/test/mocha/mocha-browser-test-entry-point.ts b/test/spec/mocha/mocha-browser-test-entry-point.ts similarity index 100% rename from test/mocha/mocha-browser-test-entry-point.ts rename to test/spec/mocha/mocha-browser-test-entry-point.ts diff --git a/test/mocha/mocha-node-test-entry-point.ts b/test/spec/mocha/mocha-node-test-entry-point.ts similarity index 63% rename from test/mocha/mocha-node-test-entry-point.ts rename to test/spec/mocha/mocha-node-test-entry-point.ts index e77cf2941..7c0174ec0 100644 --- a/test/mocha/mocha-node-test-entry-point.ts +++ b/test/spec/mocha/mocha-node-test-entry-point.ts @@ -5,7 +5,7 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ -import '../../lib/node/rollup-main'; -import '../../lib/mocha/mocha-node-checker'; -import '../../lib/testing/zone-testing'; +import '../../../lib/node/rollup-main'; +import '../../../lib/mocha/mocha-node-checker'; +import '../../../lib/testing/zone-testing'; import './jasmine-bridge.spec'; \ No newline at end of file diff --git a/test/mocha/mocha-patch.spec.ts b/test/spec/mocha/mocha-patch.spec.ts similarity index 92% rename from test/mocha/mocha-patch.spec.ts rename to test/spec/mocha/mocha-patch.spec.ts index a4f34ffaa..cd5e70598 100644 --- a/test/mocha/mocha-patch.spec.ts +++ b/test/spec/mocha/mocha-patch.spec.ts @@ -44,7 +44,6 @@ ifEnvSupports('Mocha', function() { beforeEach(() => { beforeEachZone = Zone.current; - console.log('beforeEach'); }); it('should throw on async in describe', () => { @@ -67,13 +66,11 @@ ifEnvSupports('Mocha', function() { }); /*suite('Mocha TDD-style', () => { - console.log('suite', this && this.constructor); let testZone: Zone = null; let beforeEachZone: Zone = null; let suiteSetupZone: Zone = null; suiteSetup(() => { - console.log('suiteSetup', this && this.constructor); suiteSetupZone = Zone.current; }); @@ -82,7 +79,6 @@ ifEnvSupports('Mocha', function() { }); test('should run in Zone with "test"-syntax in TDD-mode', () => { - console.log('test', this && this.constructor); testZone = Zone.current; expect(Zone.currentTask).toBeTruthy(); expect(testZone.name).toEqual('ProxyZone'); @@ -124,4 +120,20 @@ ifEnvSupports('Mocha', function() { expect(log).toEqual(['resolved']); }); }); + + xdescribe('timeout', () => { + beforeEach(function () { + this.timeout(10000); + }); + + it('longtime work', (done: DoneFn) => { + setTimeout(done, 6000); + }); + }); + + describe('skip', () => { + it('skip this case', function() { + this.skip(); + }); + }); })(); \ No newline at end of file diff --git a/test/node/Error.spec.ts b/test/spec/node/Error.spec.ts similarity index 100% rename from test/node/Error.spec.ts rename to test/spec/node/Error.spec.ts diff --git a/test/node/console.spec.ts b/test/spec/node/console.spec.ts similarity index 100% rename from test/node/console.spec.ts rename to test/spec/node/console.spec.ts diff --git a/test/node/crypto.spec.ts b/test/spec/node/crypto.spec.ts similarity index 100% rename from test/node/crypto.spec.ts rename to test/spec/node/crypto.spec.ts diff --git a/test/node/events.spec.ts b/test/spec/node/events.spec.ts similarity index 100% rename from test/node/events.spec.ts rename to test/spec/node/events.spec.ts diff --git a/test/node/fs.spec.ts b/test/spec/node/fs.spec.ts similarity index 100% rename from test/node/fs.spec.ts rename to test/spec/node/fs.spec.ts diff --git a/test/node/http.spec.ts b/test/spec/node/http.spec.ts similarity index 100% rename from test/node/http.spec.ts rename to test/spec/node/http.spec.ts diff --git a/test/node/process.spec.ts b/test/spec/node/process.spec.ts similarity index 83% rename from test/node/process.spec.ts rename to test/spec/node/process.spec.ts index 761eba652..eac6bae6d 100644 --- a/test/node/process.spec.ts +++ b/test/spec/node/process.spec.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {zoneSymbol} from '../../lib/common/utils'; +import {zoneSymbol} from '../../../lib/common/utils'; describe('process related test', () => { let zoneA: Zone, result: any[]; @@ -39,16 +39,18 @@ describe('process related test', () => { it('process.nextTick should be treated as microTask', (done) => { let zoneTick = Zone.current.fork({ name: 'zoneTick', - onScheduleTask: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - task: Task): Task => { - result.push({callback: 'scheduleTask', targetZone: targetZone.name, task: task.source}); - return parentZoneDelegate.scheduleTask(targetZone, task); - }, - onInvokeTask: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - task: Task, applyThis?: any, applyArgs?: any): any => { - result.push({callback: 'invokeTask', targetZone: targetZone.name, task: task.source}); - return parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs); - } + onScheduleTask: ( + parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): + Task => { + result.push({callback: 'scheduleTask', targetZone: targetZone.name, task: task.source}); + return parentZoneDelegate.scheduleTask(targetZone, task); + }, + onInvokeTask: + (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task, + applyThis?: any, applyArgs?: any): any => { + result.push({callback: 'invokeTask', targetZone: targetZone.name, task: task.source}); + return parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs); + } }); zoneTick.run(() => { process.nextTick(() => { diff --git a/test/patch/IndexedDB.spec.js b/test/spec/patch/IndexedDB.spec.js similarity index 100% rename from test/patch/IndexedDB.spec.js rename to test/spec/patch/IndexedDB.spec.js diff --git a/promise-adapter.js b/test/spec/promise/promise-adapter.js similarity index 83% rename from promise-adapter.js rename to test/spec/promise/promise-adapter.js index ea81bddfb..dfa369e63 100644 --- a/promise-adapter.js +++ b/test/spec/promise/promise-adapter.js @@ -1,4 +1,4 @@ -require('./dist/zone-node.js'); +require('../../../dist/zone-node.js'); Zone[('__zone_symbol__ignoreConsoleErrorUncaughtError')] = true; module.exports.deferred = function() { const p = {}; @@ -14,5 +14,5 @@ module.exports.resolved = (val) => { }; module.exports.rejected = (reason) => { - return Promise.reject(reason); + return Promise.reject(reason); }; diff --git a/test/spec/promise/promise.finally.spec.js b/test/spec/promise/promise.finally.spec.js new file mode 100644 index 000000000..8463fc339 --- /dev/null +++ b/test/spec/promise/promise.finally.spec.js @@ -0,0 +1,392 @@ +'use strict'; + +var assert = require('assert'); +var adapter = require('./promise-adapter'); +var P = global['__zone_symbol__Promise']; + +var someRejectionReason = {message: 'some rejection reason'}; +var anotherReason = {message: 'another rejection reason'}; +process.on('unhandledRejection', function(reason, promise) { + console.log('unhandledRejection', reason); +}); + +describe('mocha promise sanity check', () => { + it('passes with a resolved promise', () => { + return P.resolve(3); + }); + + it('passes with a rejected then resolved promise', () => { + return P.reject(someRejectionReason).catch(x => 'this should be resolved'); + }); + + var ifPromiseIt = P === Promise ? it : it.skip; + ifPromiseIt('is the native Promise', () => { + assert.equal(P, Promise); + }); +}); + +describe('onFinally', () => { + describe('no callback', () => { + specify('from resolved', (done) => { + adapter.resolved(3) + .then((x) => { + assert.strictEqual(x, 3); + return x; + }) + .finally() + .then( + function onFulfilled(x) { + assert.strictEqual(x, 3); + done(); + }, + function onRejected() { + done(new Error('should not be called')); + }); + }); + + specify('from rejected', (done) => { + adapter.rejected(someRejectionReason) + .catch((e) => { + assert.strictEqual(e, someRejectionReason); + throw e; + }) + .finally() + .then( + function onFulfilled() { + done(new Error('should not be called')); + }, + function onRejected(reason) { + assert.strictEqual(reason, someRejectionReason); + done(); + }); + }); + }); + + describe('throws an exception', () => { + specify('from resolved', (done) => { + adapter.resolved(3) + .then((x) => { + assert.strictEqual(x, 3); + return x; + }) + .finally(function onFinally() { + assert(arguments.length === 0); + throw someRejectionReason; + }) + .then( + function onFulfilled() { + done(new Error('should not be called')); + }, + function onRejected(reason) { + assert.strictEqual(reason, someRejectionReason); + done(); + }); + }); + + specify('from rejected', (done) => { + adapter.rejected(anotherReason) + .finally(function onFinally() { + assert(arguments.length === 0); + throw someRejectionReason; + }) + .then( + function onFulfilled() { + done(new Error('should not be called')); + }, + function onRejected(reason) { + assert.strictEqual(reason, someRejectionReason); + done(); + }); + }); + }); + + describe('returns a non-promise', () => { + specify('from resolved', (done) => { + adapter.resolved(3) + .then((x) => { + assert.strictEqual(x, 3); + return x; + }) + .finally(function onFinally() { + assert(arguments.length === 0); + return 4; + }) + .then( + function onFulfilled(x) { + assert.strictEqual(x, 3); + done(); + }, + function onRejected() { + done(new Error('should not be called')); + }); + }); + + specify('from rejected', (done) => { + adapter.rejected(anotherReason) + .catch((e) => { + assert.strictEqual(e, anotherReason); + throw e; + }) + .finally(function onFinally() { + assert(arguments.length === 0); + throw someRejectionReason; + }) + .then( + function onFulfilled() { + done(new Error('should not be called')); + }, + function onRejected(e) { + assert.strictEqual(e, someRejectionReason); + done(); + }); + }); + }); + + describe('returns a pending-forever promise', () => { + specify('from resolved', (done) => { + var timeout; + adapter.resolved(3) + .then((x) => { + assert.strictEqual(x, 3); + return x; + }) + .finally(function onFinally() { + assert(arguments.length === 0); + timeout = setTimeout(done, 0.1e3); + return new P(() => {}); // forever pending + }) + .then( + function onFulfilled(x) { + clearTimeout(timeout); + done(new Error('should not be called')); + }, + function onRejected() { + clearTimeout(timeout); + done(new Error('should not be called')); + }); + }); + + specify('from rejected', (done) => { + var timeout; + adapter.rejected(someRejectionReason) + .catch((e) => { + assert.strictEqual(e, someRejectionReason); + throw e; + }) + .finally(function onFinally() { + assert(arguments.length === 0); + timeout = setTimeout(done, 0.1e3); + return new P(() => {}); // forever pending + }) + .then( + function onFulfilled(x) { + clearTimeout(timeout); + done(new Error('should not be called')); + }, + function onRejected() { + clearTimeout(timeout); + done(new Error('should not be called')); + }); + }); + }); + + describe('returns an immediately-fulfilled promise', () => { + specify('from resolved', (done) => { + adapter.resolved(3) + .then((x) => { + assert.strictEqual(x, 3); + return x; + }) + .finally(function onFinally() { + assert(arguments.length === 0); + return adapter.resolved(4); + }) + .then( + function onFulfilled(x) { + assert.strictEqual(x, 3); + done(); + }, + function onRejected() { + done(new Error('should not be called')); + }); + }); + + specify('from rejected', (done) => { + adapter.rejected(someRejectionReason) + .catch((e) => { + assert.strictEqual(e, someRejectionReason); + throw e; + }) + .finally(function onFinally() { + assert(arguments.length === 0); + return adapter.resolved(4); + }) + .then( + function onFulfilled() { + done(new Error('should not be called')); + }, + function onRejected(e) { + assert.strictEqual(e, someRejectionReason); + done(); + }); + }); + }); + + describe('returns an immediately-rejected promise', () => { + specify('from resolved ', (done) => { + adapter.resolved(3) + .then((x) => { + assert.strictEqual(x, 3); + return x; + }) + .finally(function onFinally() { + assert(arguments.length === 0); + return adapter.rejected(4); + }) + .then( + function onFulfilled(x) { + done(new Error('should not be called')); + }, + function onRejected(e) { + assert.strictEqual(e, 4); + done(); + }); + }); + + specify('from rejected', (done) => { + const newReason = {}; + adapter.rejected(someRejectionReason) + .catch((e) => { + assert.strictEqual(e, someRejectionReason); + throw e; + }) + .finally(function onFinally() { + assert(arguments.length === 0); + return adapter.rejected(newReason); + }) + .then( + function onFulfilled(x) { + done(new Error('should not be called')); + }, + function onRejected(e) { + assert.strictEqual(e, newReason); + done(); + }); + }); + }); + + describe('returns a fulfilled-after-a-second promise', () => { + specify('from resolved', (done) => { + var timeout; + adapter.resolved(3) + .then((x) => { + assert.strictEqual(x, 3); + return x; + }) + .finally(function onFinally() { + assert(arguments.length === 0); + timeout = setTimeout(done, 1.5e3); + return new P((resolve) => { + setTimeout(() => resolve(4), 1e3); + }); + }) + .then( + function onFulfilled(x) { + clearTimeout(timeout); + assert.strictEqual(x, 3); + done(); + }, + function onRejected() { + clearTimeout(timeout); + done(new Error('should not be called')); + }); + }); + + specify('from rejected', (done) => { + var timeout; + adapter.rejected(3) + .catch((e) => { + assert.strictEqual(e, 3); + throw e; + }) + .finally(function onFinally() { + assert(arguments.length === 0); + timeout = setTimeout(done, 1.5e3); + return new P((resolve) => { + setTimeout(() => resolve(4), 1e3); + }); + }) + .then( + function onFulfilled() { + clearTimeout(timeout); + done(new Error('should not be called')); + }, + function onRejected(e) { + clearTimeout(timeout); + assert.strictEqual(e, 3); + done(); + }); + }); + }); + + describe('returns a rejected-after-a-second promise', () => { + specify('from resolved', (done) => { + var timeout; + adapter.resolved(3) + .then((x) => { + assert.strictEqual(x, 3); + return x; + }) + .finally(function onFinally() { + assert(arguments.length === 0); + timeout = setTimeout(done, 1.5e3); + return new P((resolve, reject) => { + setTimeout(() => reject(4), 1e3); + }); + }) + .then( + function onFulfilled() { + clearTimeout(timeout); + done(new Error('should not be called')); + }, + function onRejected(e) { + clearTimeout(timeout); + assert.strictEqual(e, 4); + done(); + }); + }); + + specify('from rejected', (done) => { + var timeout; + adapter.rejected(someRejectionReason) + .catch((e) => { + assert.strictEqual(e, someRejectionReason); + throw e; + }) + .finally(function onFinally() { + assert(arguments.length === 0); + timeout = setTimeout(done, 1.5e3); + return new P((resolve, reject) => { + setTimeout(() => reject(anotherReason), 1e3); + }); + }) + .then( + function onFulfilled() { + clearTimeout(timeout); + done(new Error('should not be called')); + }, + function onRejected(e) { + clearTimeout(timeout); + assert.strictEqual(e, anotherReason); + done(); + }); + }); + }); + + specify('has the correct property descriptor', () => { + var descriptor = Object.getOwnPropertyDescriptor(Promise.prototype, 'finally'); + + assert.strictEqual(descriptor.writable, true); + assert.strictEqual(descriptor.configurable, true); + }); +}); \ No newline at end of file diff --git a/test/rxjs/rxjs.Observable.audit.spec.ts b/test/spec/rxjs/rxjs.Observable.audit.spec.ts similarity index 100% rename from test/rxjs/rxjs.Observable.audit.spec.ts rename to test/spec/rxjs/rxjs.Observable.audit.spec.ts diff --git a/test/rxjs/rxjs.Observable.buffer.spec.ts b/test/spec/rxjs/rxjs.Observable.buffer.spec.ts similarity index 100% rename from test/rxjs/rxjs.Observable.buffer.spec.ts rename to test/spec/rxjs/rxjs.Observable.buffer.spec.ts diff --git a/test/rxjs/rxjs.Observable.catch.spec.ts b/test/spec/rxjs/rxjs.Observable.catch.spec.ts similarity index 100% rename from test/rxjs/rxjs.Observable.catch.spec.ts rename to test/spec/rxjs/rxjs.Observable.catch.spec.ts diff --git a/test/rxjs/rxjs.Observable.collection.spec.ts b/test/spec/rxjs/rxjs.Observable.collection.spec.ts similarity index 100% rename from test/rxjs/rxjs.Observable.collection.spec.ts rename to test/spec/rxjs/rxjs.Observable.collection.spec.ts diff --git a/test/rxjs/rxjs.Observable.combine.spec.ts b/test/spec/rxjs/rxjs.Observable.combine.spec.ts similarity index 100% rename from test/rxjs/rxjs.Observable.combine.spec.ts rename to test/spec/rxjs/rxjs.Observable.combine.spec.ts diff --git a/test/rxjs/rxjs.Observable.concat.spec.ts b/test/spec/rxjs/rxjs.Observable.concat.spec.ts similarity index 100% rename from test/rxjs/rxjs.Observable.concat.spec.ts rename to test/spec/rxjs/rxjs.Observable.concat.spec.ts diff --git a/test/rxjs/rxjs.Observable.count.spec.ts b/test/spec/rxjs/rxjs.Observable.count.spec.ts similarity index 100% rename from test/rxjs/rxjs.Observable.count.spec.ts rename to test/spec/rxjs/rxjs.Observable.count.spec.ts diff --git a/test/rxjs/rxjs.Observable.debounce.spec.ts b/test/spec/rxjs/rxjs.Observable.debounce.spec.ts similarity index 100% rename from test/rxjs/rxjs.Observable.debounce.spec.ts rename to test/spec/rxjs/rxjs.Observable.debounce.spec.ts diff --git a/test/rxjs/rxjs.Observable.default.spec.ts b/test/spec/rxjs/rxjs.Observable.default.spec.ts similarity index 100% rename from test/rxjs/rxjs.Observable.default.spec.ts rename to test/spec/rxjs/rxjs.Observable.default.spec.ts diff --git a/test/rxjs/rxjs.Observable.delay.spec.ts b/test/spec/rxjs/rxjs.Observable.delay.spec.ts similarity index 100% rename from test/rxjs/rxjs.Observable.delay.spec.ts rename to test/spec/rxjs/rxjs.Observable.delay.spec.ts diff --git a/test/rxjs/rxjs.Observable.distinct.spec.ts b/test/spec/rxjs/rxjs.Observable.distinct.spec.ts similarity index 100% rename from test/rxjs/rxjs.Observable.distinct.spec.ts rename to test/spec/rxjs/rxjs.Observable.distinct.spec.ts diff --git a/test/rxjs/rxjs.Observable.do.spec.ts b/test/spec/rxjs/rxjs.Observable.do.spec.ts similarity index 100% rename from test/rxjs/rxjs.Observable.do.spec.ts rename to test/spec/rxjs/rxjs.Observable.do.spec.ts diff --git a/test/rxjs/rxjs.Observable.map.spec.ts b/test/spec/rxjs/rxjs.Observable.map.spec.ts similarity index 100% rename from test/rxjs/rxjs.Observable.map.spec.ts rename to test/spec/rxjs/rxjs.Observable.map.spec.ts diff --git a/test/rxjs/rxjs.Observable.merge.spec.ts b/test/spec/rxjs/rxjs.Observable.merge.spec.ts similarity index 100% rename from test/rxjs/rxjs.Observable.merge.spec.ts rename to test/spec/rxjs/rxjs.Observable.merge.spec.ts diff --git a/test/rxjs/rxjs.Observable.multicast.spec.ts b/test/spec/rxjs/rxjs.Observable.multicast.spec.ts similarity index 100% rename from test/rxjs/rxjs.Observable.multicast.spec.ts rename to test/spec/rxjs/rxjs.Observable.multicast.spec.ts diff --git a/test/rxjs/rxjs.Observable.notification.spec.ts b/test/spec/rxjs/rxjs.Observable.notification.spec.ts similarity index 100% rename from test/rxjs/rxjs.Observable.notification.spec.ts rename to test/spec/rxjs/rxjs.Observable.notification.spec.ts diff --git a/test/rxjs/rxjs.Observable.race.spec.ts b/test/spec/rxjs/rxjs.Observable.race.spec.ts similarity index 100% rename from test/rxjs/rxjs.Observable.race.spec.ts rename to test/spec/rxjs/rxjs.Observable.race.spec.ts diff --git a/test/rxjs/rxjs.Observable.sample.spec.ts b/test/spec/rxjs/rxjs.Observable.sample.spec.ts similarity index 100% rename from test/rxjs/rxjs.Observable.sample.spec.ts rename to test/spec/rxjs/rxjs.Observable.sample.spec.ts diff --git a/test/rxjs/rxjs.Observable.take.spec.ts b/test/spec/rxjs/rxjs.Observable.take.spec.ts similarity index 100% rename from test/rxjs/rxjs.Observable.take.spec.ts rename to test/spec/rxjs/rxjs.Observable.take.spec.ts diff --git a/test/rxjs/rxjs.Observable.timeout.spec.ts b/test/spec/rxjs/rxjs.Observable.timeout.spec.ts similarity index 100% rename from test/rxjs/rxjs.Observable.timeout.spec.ts rename to test/spec/rxjs/rxjs.Observable.timeout.spec.ts diff --git a/test/rxjs/rxjs.Observable.window.spec.ts b/test/spec/rxjs/rxjs.Observable.window.spec.ts similarity index 100% rename from test/rxjs/rxjs.Observable.window.spec.ts rename to test/spec/rxjs/rxjs.Observable.window.spec.ts diff --git a/test/rxjs/rxjs.asap.spec.ts b/test/spec/rxjs/rxjs.asap.spec.ts similarity index 100% rename from test/rxjs/rxjs.asap.spec.ts rename to test/spec/rxjs/rxjs.asap.spec.ts diff --git a/test/rxjs/rxjs.bindCallback.spec.ts b/test/spec/rxjs/rxjs.bindCallback.spec.ts similarity index 100% rename from test/rxjs/rxjs.bindCallback.spec.ts rename to test/spec/rxjs/rxjs.bindCallback.spec.ts diff --git a/test/rxjs/rxjs.bindNodeCallback.spec.ts b/test/spec/rxjs/rxjs.bindNodeCallback.spec.ts similarity index 100% rename from test/rxjs/rxjs.bindNodeCallback.spec.ts rename to test/spec/rxjs/rxjs.bindNodeCallback.spec.ts diff --git a/test/rxjs/rxjs.combineLatest.spec.ts b/test/spec/rxjs/rxjs.combineLatest.spec.ts similarity index 100% rename from test/rxjs/rxjs.combineLatest.spec.ts rename to test/spec/rxjs/rxjs.combineLatest.spec.ts diff --git a/test/rxjs/rxjs.common.spec.ts b/test/spec/rxjs/rxjs.common.spec.ts similarity index 100% rename from test/rxjs/rxjs.common.spec.ts rename to test/spec/rxjs/rxjs.common.spec.ts diff --git a/test/rxjs/rxjs.concat.spec.ts b/test/spec/rxjs/rxjs.concat.spec.ts similarity index 100% rename from test/rxjs/rxjs.concat.spec.ts rename to test/spec/rxjs/rxjs.concat.spec.ts diff --git a/test/rxjs/rxjs.defer.spec.ts b/test/spec/rxjs/rxjs.defer.spec.ts similarity index 100% rename from test/rxjs/rxjs.defer.spec.ts rename to test/spec/rxjs/rxjs.defer.spec.ts diff --git a/test/rxjs/rxjs.empty.spec.ts b/test/spec/rxjs/rxjs.empty.spec.ts similarity index 100% rename from test/rxjs/rxjs.empty.spec.ts rename to test/spec/rxjs/rxjs.empty.spec.ts diff --git a/test/rxjs/rxjs.forkjoin.spec.ts b/test/spec/rxjs/rxjs.forkjoin.spec.ts similarity index 100% rename from test/rxjs/rxjs.forkjoin.spec.ts rename to test/spec/rxjs/rxjs.forkjoin.spec.ts diff --git a/test/rxjs/rxjs.from.spec.ts b/test/spec/rxjs/rxjs.from.spec.ts similarity index 100% rename from test/rxjs/rxjs.from.spec.ts rename to test/spec/rxjs/rxjs.from.spec.ts diff --git a/test/spec/rxjs/rxjs.fromEvent.spec.ts b/test/spec/rxjs/rxjs.fromEvent.spec.ts new file mode 100644 index 000000000..2a4c19f49 --- /dev/null +++ b/test/spec/rxjs/rxjs.fromEvent.spec.ts @@ -0,0 +1,105 @@ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +import * as Rx from 'rxjs/Rx'; + +import {isBrowser} from '../../../lib/common/utils'; +import {ifEnvSupports} from '../test-util'; + +function isEventTarget() { + return isBrowser; +} + +(isEventTarget as any).message = 'EventTargetTest'; + +describe('Observable.fromEvent', () => { + let log: string[]; + const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); + const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); + const triggerZone: Zone = Zone.current.fork({name: 'Trigger Zone'}); + let observable1: any; + + beforeEach(() => { + log = []; + }); + + it('fromEvent EventTarget func callback should run in the correct zone', + ifEnvSupports(isEventTarget, () => { + observable1 = constructorZone1.run(() => { + return Rx.Observable.fromEvent(document, 'click'); + }); + + const clickEvent = document.createEvent('Event'); + clickEvent.initEvent('click', true, true); + + subscriptionZone.run(() => { + observable1.subscribe( + (result: any) => { + expect(Zone.current.name).toEqual(subscriptionZone.name); + log.push(result); + }, + () => { + fail('should not call error'); + }, + () => { + expect(Zone.current.name).toEqual(subscriptionZone.name); + log.push('completed'); + }); + }); + + triggerZone.run(() => { + document.dispatchEvent(clickEvent); + }); + + expect(log).toEqual([clickEvent]); + })); + + it('fromEventPattern EventTarget func callback should run in the correct zone', + ifEnvSupports(isEventTarget, () => { + const button = document.createElement('button'); + document.body.appendChild(button); + observable1 = constructorZone1.run(() => { + return Rx.Observable.fromEventPattern( + (handler: any) => { + expect(Zone.current.name).toEqual(constructorZone1.name); + button.addEventListener('click', handler); + log.push('addListener'); + }, + (handler: any) => { + expect(Zone.current.name).toEqual(constructorZone1.name); + button.removeEventListener('click', handler); + document.body.removeChild(button); + log.push('removeListener'); + }); + }); + + const clickEvent = document.createEvent('Event'); + clickEvent.initEvent('click', false, false); + + const subscriper: any = subscriptionZone.run(() => { + return observable1.subscribe( + (result: any) => { + expect(Zone.current.name).toEqual(subscriptionZone.name); + log.push(result); + }, + () => { + fail('should not call error'); + }, + () => { + expect(Zone.current.name).toEqual(subscriptionZone.name); + log.push('completed'); + }); + }); + + triggerZone.run(() => { + button.dispatchEvent(clickEvent); + subscriper.complete(); + }); + expect(log).toEqual(['addListener', clickEvent, 'completed', 'removeListener']); + })); +}); diff --git a/test/rxjs/rxjs.fromPromise.spec.ts b/test/spec/rxjs/rxjs.fromPromise.spec.ts similarity index 100% rename from test/rxjs/rxjs.fromPromise.spec.ts rename to test/spec/rxjs/rxjs.fromPromise.spec.ts diff --git a/test/rxjs/rxjs.interval.spec.ts b/test/spec/rxjs/rxjs.interval.spec.ts similarity index 100% rename from test/rxjs/rxjs.interval.spec.ts rename to test/spec/rxjs/rxjs.interval.spec.ts diff --git a/test/rxjs/rxjs.merge.spec.ts b/test/spec/rxjs/rxjs.merge.spec.ts similarity index 100% rename from test/rxjs/rxjs.merge.spec.ts rename to test/spec/rxjs/rxjs.merge.spec.ts diff --git a/test/rxjs/rxjs.never.spec.ts b/test/spec/rxjs/rxjs.never.spec.ts similarity index 100% rename from test/rxjs/rxjs.never.spec.ts rename to test/spec/rxjs/rxjs.never.spec.ts diff --git a/test/rxjs/rxjs.of.spec.ts b/test/spec/rxjs/rxjs.of.spec.ts similarity index 100% rename from test/rxjs/rxjs.of.spec.ts rename to test/spec/rxjs/rxjs.of.spec.ts diff --git a/test/rxjs/rxjs.range.spec.ts b/test/spec/rxjs/rxjs.range.spec.ts similarity index 100% rename from test/rxjs/rxjs.range.spec.ts rename to test/spec/rxjs/rxjs.range.spec.ts diff --git a/test/rxjs/rxjs.spec.ts b/test/spec/rxjs/rxjs.spec.ts similarity index 98% rename from test/rxjs/rxjs.spec.ts rename to test/spec/rxjs/rxjs.spec.ts index 8a42b0fe2..547b46d00 100644 --- a/test/rxjs/rxjs.spec.ts +++ b/test/spec/rxjs/rxjs.spec.ts @@ -5,7 +5,7 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ -import '../../lib/rxjs/rxjs'; +import '../../../lib/rxjs/rxjs'; import './rxjs.common.spec'; import './rxjs.asap.spec'; import './rxjs.bindCallback.spec'; diff --git a/test/rxjs/rxjs.throw.spec.ts b/test/spec/rxjs/rxjs.throw.spec.ts similarity index 100% rename from test/rxjs/rxjs.throw.spec.ts rename to test/spec/rxjs/rxjs.throw.spec.ts diff --git a/test/rxjs/rxjs.timer.spec.ts b/test/spec/rxjs/rxjs.timer.spec.ts similarity index 100% rename from test/rxjs/rxjs.timer.spec.ts rename to test/spec/rxjs/rxjs.timer.spec.ts diff --git a/test/rxjs/rxjs.zip.spec.ts b/test/spec/rxjs/rxjs.zip.spec.ts similarity index 100% rename from test/rxjs/rxjs.zip.spec.ts rename to test/spec/rxjs/rxjs.zip.spec.ts diff --git a/test/test-util.ts b/test/spec/test-util.ts similarity index 100% rename from test/test-util.ts rename to test/spec/test-util.ts diff --git a/simple-server.js b/test/spec/webdriver/simple-server.js similarity index 97% rename from simple-server.js rename to test/spec/webdriver/simple-server.js index 71a186a09..cac630629 100644 --- a/simple-server.js +++ b/test/spec/webdriver/simple-server.js @@ -9,7 +9,7 @@ const http = require('http'); const path = require('path'); const fs = require('fs'); -let server; +let server; const localFolder = __dirname; @@ -21,7 +21,7 @@ function requestHandler(req, res) { }, 1000); } else { const file = localFolder + req.url; - + fs.readFile(file, function(err, contents) { if(!err){ res.end(contents); @@ -32,5 +32,5 @@ function requestHandler(req, res) { }); }; }; - + server = http.createServer(requestHandler).listen(8080); \ No newline at end of file diff --git a/test/webdriver/test.html b/test/spec/webdriver/test.html similarity index 65% rename from test/webdriver/test.html rename to test/spec/webdriver/test.html index 0fa9c32ff..c96642559 100644 --- a/test/webdriver/test.html +++ b/test/spec/webdriver/test.html @@ -1,7 +1,7 @@ - +
Hello Zones!
diff --git a/test/webdriver/test.js b/test/spec/webdriver/test.js similarity index 100% rename from test/webdriver/test.js rename to test/spec/webdriver/test.js diff --git a/test/webdriver/test.sauce.js b/test/spec/webdriver/test.sauce.js similarity index 95% rename from test/webdriver/test.sauce.js rename to test/spec/webdriver/test.sauce.js index 7ca9de2ef..0cda43c5d 100644 --- a/test/webdriver/test.sauce.js +++ b/test/spec/webdriver/test.sauce.js @@ -21,12 +21,12 @@ const desiredCapabilities = { edge14: { browserName: 'MicrosoftEdge', platform: 'Windows 10', - version: '14.14393' + version: '14.14393' }, /*edge15: { browserName: 'Edge', platform: 'Windows 10', - version: '15.15063' + version: '15.15063' },*/ chrome48: { browserName: 'chrome', @@ -104,15 +104,15 @@ Object.keys(desiredCapabilities).forEach(key => { key: process.env.SAUCE_ACCESS_KEY, host: 'localhost', port: 4445, - desiredCapabilities: desiredCapabilities[key] + desiredCapabilities: desiredCapabilities[key] }); const p = client .init() .timeouts('script', 60000) - .url('http://localhost:8080/test/webdriver/test.html') + .url('http://localhost:8080/test.html') .executeAsync(function(done) { window.setTimeout(done,1000) }) - .execute(function() + .execute(function() { const elem = document.getElementById('thetext'); const zone = window['Zone'] ? Zone.current.fork({name: 'webdriver'}) : null; diff --git a/test/zone-spec/async-test.spec.ts b/test/spec/zone-spec/async-test.spec.ts similarity index 100% rename from test/zone-spec/async-test.spec.ts rename to test/spec/zone-spec/async-test.spec.ts diff --git a/test/zone-spec/fake-async-test.spec.ts b/test/spec/zone-spec/fake-async-test.spec.ts similarity index 99% rename from test/zone-spec/fake-async-test.spec.ts rename to test/spec/zone-spec/fake-async-test.spec.ts index f92f1b96b..e6199da32 100644 --- a/test/zone-spec/fake-async-test.spec.ts +++ b/test/spec/zone-spec/fake-async-test.spec.ts @@ -7,11 +7,11 @@ */ import 'rxjs/add/operator/delay'; -import '../../lib/rxjs/rxjs-fake-async'; +import '../../../lib/rxjs/rxjs-fake-async'; import {Observable} from 'rxjs/Observable'; -import {isNode, patchMacroTask} from '../../lib/common/utils'; +import {isNode, patchMacroTask} from '../../../lib/common/utils'; import {ifEnvSupports} from '../test-util'; function supportNode() { @@ -309,9 +309,9 @@ describe('FakeAsyncTestZoneSpec', () => { let id: number; id = setInterval(() => { - cycles++; - clearInterval(id); - }, 10) as any as number; + cycles++; + clearInterval(id); + }, 10) as any as number; testZoneSpec.tick(10); expect(cycles).toEqual(1); @@ -774,7 +774,6 @@ describe('FakeAsyncTestZoneSpec', () => { expect(tickRun).toEqual(true); expect(cbArgRun).toEqual(true); }); - }); })); @@ -944,7 +943,6 @@ describe('FakeAsyncTestZoneSpec', () => { expect(unixTimeZero).toBe(0); }); }); - }); describe( @@ -1272,7 +1270,6 @@ const {fakeAsync, tick, discardPeriodicTasks, flush, flushMicrotasks} = fakeAsyn })(); }).toThrowError('sync'); }); - }); describe('timers', () => { diff --git a/test/zone-spec/long-stack-trace-zone.spec.ts b/test/spec/zone-spec/long-stack-trace-zone.spec.ts similarity index 93% rename from test/zone-spec/long-stack-trace-zone.spec.ts rename to test/spec/zone-spec/long-stack-trace-zone.spec.ts index 4515c2965..e040afdbb 100644 --- a/test/zone-spec/long-stack-trace-zone.spec.ts +++ b/test/spec/zone-spec/long-stack-trace-zone.spec.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {isBrowser, zoneSymbol} from '../../lib/common/utils'; +import {isBrowser, zoneSymbol} from '../../../lib/common/utils'; import {ifEnvSupports, isSupportSetErrorStack} from '../test-util'; const defineProperty = (Object as any)[zoneSymbol('defineProperty')] || Object.defineProperty; @@ -21,12 +21,13 @@ describe( beforeEach(function() { lstz = Zone.current.fork(longStackTraceZoneSpec).fork({ name: 'long-stack-trace-zone-test', - onHandleError: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - error: any): boolean => { - parentZoneDelegate.handleError(targetZone, error); - log.push(error); - return false; - } + onHandleError: + (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, error: any): + boolean => { + parentZoneDelegate.handleError(targetZone, error); + log.push(error); + return false; + } }); log = []; diff --git a/test/zone-spec/proxy.spec.ts b/test/spec/zone-spec/proxy.spec.ts similarity index 100% rename from test/zone-spec/proxy.spec.ts rename to test/spec/zone-spec/proxy.spec.ts diff --git a/test/zone-spec/sync-test.spec.ts b/test/spec/zone-spec/sync-test.spec.ts similarity index 100% rename from test/zone-spec/sync-test.spec.ts rename to test/spec/zone-spec/sync-test.spec.ts diff --git a/test/zone-spec/task-tracking.spec.ts b/test/spec/zone-spec/task-tracking.spec.ts similarity index 100% rename from test/zone-spec/task-tracking.spec.ts rename to test/spec/zone-spec/task-tracking.spec.ts