Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit f478889

Browse files
committed
refactor(test): refactor folder of test/build/ci
1 parent cc57de2 commit f478889

File tree

167 files changed

+968
-900
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

167 files changed

+968
-900
lines changed

.travis.yml

+8-9
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,19 @@ script:
3535
- node_modules/.bin/gulp promisetest
3636
- yarn promisefinallytest
3737
- yarn test:phantomjs-single
38-
- node_modules/.bin/karma start karma-dist-sauce-jasmine.conf.js --single-run
39-
- node_modules/.bin/karma start karma-build-sauce-mocha.conf.js --single-run
40-
- node_modules/.bin/karma start karma-dist-sauce-selenium3-jasmine.conf.js --single-run
41-
- node_modules/.bin/karma start karma-build-sauce-selenium3-mocha.conf.js --single-run
38+
- node_modules/.bin/karma start ./test/karma/ci/dist/karma-dist-sauce-jasmine.conf.js --single-run
39+
- node_modules/.bin/karma start ./test/karma/ci/build/karma-build-sauce-mocha.conf.js --single-run
40+
- node_modules/.bin/karma start ./test/karma/ci/dist/karma-dist-sauce-selenium3-jasmine.conf.js --single-run
41+
- node_modules/.bin/karma start ./test/karma/ci/build/karma-build-sauce-selenium3-mocha.conf.js --single-run
4242
- node_modules/.bin/gulp test/node
4343
- node_modules/.bin/gulp test/node -no-patch-clock
4444
- node_modules/.bin/gulp test/bluebird
45-
- node simple-server.js 2>&1> server.log&
46-
- node ./test/webdriver/test.sauce.js
45+
- node ./test/spec/webdriver/simple-server.js 2>&1> server.log&
46+
- node ./test/spec/webdriver/test.sauce.js
4747
4848
- yarn test:phantomjs-single
4949
- yarn test-mocha-jasmine-bridge-node
50-
- yarn test-mocha-jasmine-bridge-browser
51-
- node_modules/.bin/karma start karma-dist-sauce-jasmine3.conf.js --single-run
52-
- node_modules/.bin/karma start karma-build-sauce-selenium3-mocha.conf.js --single-run
50+
- node_modules/.bin/karma start ./test/karma/ci/dist/karma-dist-sauce-jasmine3.conf.js --single-run
51+
- node_modules/.bin/karma start ./test/karma/ci/build/karma-build-sauce-selenium3-mocha.conf.js --single-run
5352
- node_modules/.bin/gulp test/node
5453
- node_modules/.bin/gulp test/node -no-patch-clock

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Implements _Zones_ for JavaScript, inspired by [Dart](https://www.dartlang.org/articles/zones/).
77

88
> If you're using zone.js via unpkg (i.e. using `https://unpkg.com/zone.js`)
9-
> and you're using any of the following libraries, make sure you import them first
9+
> and you're using any of the following libraries, make sure you import them first
1010
1111
> * 'newrelic' as it patches global.Promise before zone.js does
1212
> * '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:
3636
## Standard API support
3737

3838
zone.js patched most standard web APIs (such as DOM events, `XMLHttpRequest`, ...) and nodejs APIs
39-
(`EventEmitter`, `fs`, ...), for more details, please see [STANDARD-APIS.md](STANDARD-APIS.md).
39+
(`EventEmitter`, `fs`, ...), for more details, please see [STANDARD-APIS.md](./doc/design/STANDARD-APIS.md).
4040

4141
## Nonstandard API support
4242

4343
We are adding support to some nonstandard APIs, such as MediaQuery and
44-
Notification. Please see [NON-STANDARD-APIS.md](NON-STANDARD-APIS.md) for more details.
44+
Notification. Please see [NON-STANDARD-APIS.md](./doc/design/NON-STANDARD-APIS.md) for more details.
4545

4646
## Modules
4747

4848
zone.js patches the async APIs described above, but those patches will have some overhead.
4949
Starting from zone.js v0.8.9, you can choose which web API module you want to patch.
5050
For more details, please
51-
see [MODULE.md](MODULE.md).
51+
see [MODULE.md](./doc/design/MODULE.md).
5252

5353
## Promise A+ test passed
5454
[![Promises/A+ 1.1 compliant](https://promisesaplus.com/assets/logo-small.png)](https://promisesaplus.com/)

MODULE.md doc/design/MODULE.md

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

doc/task.md doc/lifecycle/task.md

File renamed without changes.

gulpfile.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -404,9 +404,8 @@ function nodeTest(specFiles, cb) {
404404
require('./build/lib/node/rollup-main');
405405
var args = process.argv;
406406
if (args.length > 3) {
407-
require('./build/test/test-env-setup-jasmine' + args[3]);
407+
require('./build/test/env/config/test-env-setup-jasmine' + args[3]);
408408
}
409-
var JasmineRunner = require('jasmine');
410409
var JasmineRunner = require('jasmine');
411410
var jrunner = new JasmineRunner();
412411

@@ -433,12 +432,12 @@ function nodeTest(specFiles, cb) {
433432
}
434433

435434
gulp.task('test/node', ['compile-node'], function(cb) {
436-
var specFiles = ['build/test/node_entry_point.js'];
435+
var specFiles = ['build/test/env/node/node_entry_point.js'];
437436
nodeTest(specFiles, cb);
438437
});
439438

440439
gulp.task('test/bluebird', ['compile-node'], function(cb) {
441-
var specFiles = ['build/test/node_bluebird_entry_point.js'];
440+
var specFiles = ['build/test/env/node/node_bluebird_entry_point.js'];
442441
nodeTest(specFiles, cb);
443442
});
444443

@@ -498,7 +497,7 @@ gulp.task('changelog', () => {
498497
// run promise aplus test
499498
gulp.task('promisetest', ['build/zone-node.js'], (cb) => {
500499
const promisesAplusTests = require('promises-aplus-tests');
501-
const adapter = require('./promise-adapter');
500+
const adapter = require('./test/spec/promise/promise-adapter');
502501
promisesAplusTests(adapter, {reporter: 'dot'}, function(err) {
503502
if (err) {
504503
cb(err);
@@ -510,8 +509,8 @@ gulp.task('promisetest', ['build/zone-node.js'], (cb) => {
510509

511510
// check dist file size limitation
512511
gulp.task('filesize', ['build'], (cb) => {
513-
const checker = require('./check-file-size');
514-
const result = checker(require('./file-size-limit.json'));
512+
const checker = require('./scripts/size/check-file-size');
513+
const result = checker(require('./scripts/size/file-size-limit.json'));
515514
if (result) {
516515
cb();
517516
} else {

karma-dist-sauce-jasmine3.conf.js

-12
This file was deleted.

lib/jasmine/jasmine-patch.ts

+9-21
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
'use strict';
1010
import {patchJasmineClock} from './jasmine.clock';
11+
import { mappingMochaMethods } from './mocha-bridge/mocha.bdd';
1112
Zone.__load_patch('jasmine', (global: any) => {
1213
const __extends = function(d: any, b: any) {
1314
for (const p in b)
@@ -24,7 +25,7 @@ Zone.__load_patch('jasmine', (global: any) => {
2425
// not using jasmine, just return;
2526
return;
2627
}
27-
if ((jasmine as any)['__zone_symbol__isMochaBridge']) {
28+
if ((jasmine as any)['__zone_symbol__isBridge']) {
2829
// jasmine is a mock bridge
2930
return;
3031
}
@@ -61,23 +62,17 @@ Zone.__load_patch('jasmine', (global: any) => {
6162
jasmineEnv[symbol(methodName)] = originalJasmineFn;
6263
jasmineEnv[methodName] = function(
6364
description: string, specDefinitions: Function, timeout: number) {
64-
if (typeof timeout !== 'number') {
65-
timeout = (jasmine as any)[symbol('mochaTimeout')];
66-
}
6765
const wrappedSpecDef = wrapTestInZone(specDefinitions);
6866
return originalJasmineFn.apply(
6967
this,
7068
typeof timeout === 'number' ? [description, wrappedSpecDef, timeout] :
7169
[description, wrappedSpecDef]);
7270
};
7371
});
74-
['beforeEach', 'afterEach'].forEach(methodName => {
72+
['beforeAll', 'afterAll', 'beforeEach', 'afterEach'].forEach(methodName => {
7573
let originalJasmineFn: Function = jasmineEnv[methodName];
7674
jasmineEnv[symbol(methodName)] = originalJasmineFn;
7775
jasmineEnv[methodName] = function(specDefinitions: Function, timeout: number) {
78-
if (typeof timeout !== 'number') {
79-
timeout = (jasmine as any)[symbol('mochaTimeout')];
80-
}
8176
const wrappedSpecDef = wrapTestInZone(specDefinitions);
8277
return originalJasmineFn.apply(
8378
this, typeof timeout === 'number' ? [wrappedSpecDef, timeout] : [wrappedSpecDef]);
@@ -91,19 +86,7 @@ Zone.__load_patch('jasmine', (global: any) => {
9186
*/
9287
function wrapDescribeInZone(describeBody: Function): Function {
9388
return function() {
94-
(jasmine as any)[symbol('mochaTimeout')] = null;
95-
if (this && !this.timeout) {
96-
this.timeout = function(timeout: number) {
97-
(jasmine as any)[symbol('mochaTimeout')] = timeout;
98-
}
99-
}
100-
if (this && !this.skip) {
101-
this.skip = function() {
102-
if (typeof global['pending'] === 'function') {
103-
global['pending']();
104-
}
105-
}
106-
}
89+
mappingMochaMethods(jasmine, global, this);
10790
return syncZone.run(describeBody, this, (arguments as any) as any[]);
10891
};
10992
}
@@ -119,6 +102,7 @@ Zone.__load_patch('jasmine', (global: any) => {
119102
testBody = fakeAsyncModule.fakeAsync(testBody);
120103
}
121104
}
105+
mappingMochaMethods(jasmine, global, applyThis);
122106
if (done) {
123107
return testProxyZone.run(testBody, applyThis, [done]);
124108
} else {
@@ -170,6 +154,10 @@ Zone.__load_patch('jasmine', (global: any) => {
170154
// All functions are done, clear the test zone.
171155
this.testProxyZone = null;
172156
this.testProxyZoneSpec = null;
157+
const originalTimeout = (jasmine as any)['__zone_symbol__DEFAULT_TIMEOUT_INTERVAL'];
158+
if (typeof originalTimeout === 'number') {
159+
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
160+
}
173161
ambientZone.scheduleMicroTask('jasmine.onComplete', fn);
174162
})(attrs.onComplete);
175163

lib/jasmine/mocha-bridge/mocha.bdd.ts

+17
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,21 @@ export function mappingBDD(Mocha: any, jasmine: any, global: any) {
2525
target[mocha] = global[jasmine];
2626
}
2727
});
28+
}
29+
30+
const symbol = Zone.__symbol__;
31+
export function mappingMochaMethods(jasmine: any, global: any, context: any) {
32+
if (context && !context.timeout) {
33+
context.timeout = function (timeout: number) {
34+
(jasmine as any)['__zone_symbol__DEFAULT_TIMEOUT_INTERVAL'] = jasmine.DEFAULT_TIMEOUT_INTERVAL;
35+
jasmine.DEFAULT_TIMEOUT_INTERVAL = timeout;
36+
};
37+
}
38+
if (context && !context.skip) {
39+
context.skip = function () {
40+
if (typeof global['pending'] === 'function') {
41+
global['pending']();
42+
}
43+
};
44+
}
2845
}

lib/jasmine/mocha-bridge/mocha.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Zone.__load_patch('mocha-bridge', (global: any) => {
1111
return;
1212
}
1313
global.Mocha = {};
14-
global.Mocha['__zone_symbol__isJasmineBridge'] = true;
14+
// set a flag to tell global.Mocha is a mock.
15+
global.Mocha['__zone_symbol__isBridge'] = true;
1516
mappingBDD(global.Mocha, global.jasmine, global);
1617
});

lib/mocha/jasmine-bridge/jasmine.bdd.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export function mappingBDD(jasmine: any, Mocha: any, global: any) {
1818
const chains = mocha.split('.');
1919
let mochaMethod: any = null;
2020
for (let i = 0; i < chains.length; i++) {
21-
mochaMethod = mochaMethod ? mochaMethod[chains[i]] : Mocha[chains[i]];
21+
mochaMethod = mochaMethod ? mochaMethod[chains[i]] : global[chains[i]];
2222
}
2323
global[map.jasmine] = jasmine[map.jasmine] = function() {
2424
const args = Array.prototype.slice.call(arguments);

lib/mocha/jasmine-bridge/jasmine.ts

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Zone.__load_patch('jasmine2mocha', (global: any) => {
2222
}
2323
// create a jasmine global object
2424
jasmine = global['jasmine'] = {};
25+
jasmine['__zone_symbol__isBridge'] = true;
2526
// BDD mapping
2627
mappingBDD(jasmine, global.Mocha, global);
2728

lib/mocha/mocha-patch.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Zone.__load_patch('Mocha', (global: any, Zone: ZoneType, api: _ZonePrivate) => {
1515
return;
1616
}
1717

18-
if (Mocha['__zone_symbol__isJasmineBridge']) {
18+
if (Mocha['__zone_symbol__isBridge']) {
1919
return;
2020
}
2121

package.json

+13-13
Original file line numberDiff line numberDiff line change
@@ -19,34 +19,34 @@
1919
"ci": "npm run lint && npm run format && npm run promisetest && npm run test:single && npm run test-node",
2020
"closure:test": "scripts/closure/closure_compiler.sh",
2121
"format": "gulp format:enforce",
22-
"karma-jasmine": "karma start karma-build-jasmine.conf.js",
23-
"karma-jasmine:phantomjs": "karma start karma-build-jasmine-phantomjs.conf.js --single-run",
24-
"karma-jasmine:single": "karma start karma-build-jasmine.conf.js --single-run",
22+
"karma-jasmine": "karma start ./test/karma/common/build/karma-build-jasmine.conf.js",
23+
"karma-jasmine:phantomjs": "karma start ./test/karma/common/build/karma-build-jasmine-phantomjs.conf.js --single-run",
24+
"karma-jasmine:single": "karma start ./test/karma/common/build/karma-build-jasmine.conf.js --single-run",
2525
"karma-jasmine:autoclose": "npm run karma-jasmine:single && npm run ws-client",
2626
"karma-jasmine-phantomjs:autoclose": "npm run karma-jasmine:phantomjs && npm run ws-client",
2727
"lint": "gulp lint",
2828
"prepublish": "tsc && gulp build",
2929
"promisetest": "gulp promisetest",
30-
"promisefinallytest": "mocha promise.finally.spec.js",
30+
"promisefinallytest": "mocha ./test/spec/promise/promise.finally.spec.js",
3131
"webdriver-start": "webdriver-manager update && webdriver-manager start",
32-
"webdriver-http": "node simple-server.js",
33-
"webdriver-test": "node test/webdriver/test.js",
34-
"webdriver-sauce-test": "node test/webdriver/test.sauce.js",
35-
"ws-client": "node ./test/ws-client.js",
36-
"ws-server": "node ./test/ws-server.js",
32+
"webdriver-http": "node test/spec/webdriver/simple-server.js",
33+
"webdriver-test": "node test/spec/webdriver/test.js",
34+
"webdriver-sauce-test": "node test/spec/webdriver/test.sauce.js",
35+
"ws-client": "node ./test/env/websocket/ws-client.js",
36+
"ws-server": "node ./test/env/websocket/ws-server.js",
3737
"tsc": "tsc -p .",
3838
"tsc:w": "tsc -w -p .",
3939
"tslint": "tslint -c tslint.json 'lib/**/*.ts'",
4040
"test": "npm run tsc && concurrently \"npm run tsc:w\" \"npm run ws-server\" \"npm run karma-jasmine\"",
4141
"test:phantomjs": "npm run tsc && concurrently \"npm run tsc:w\" \"npm run ws-server\" \"npm run karma-jasmine:phantomjs\"",
4242
"test:phantomjs-single": "npm run tsc && concurrently \"npm run ws-server\" \"npm run karma-jasmine-phantomjs:autoclose\"",
4343
"test:single": "npm run tsc && concurrently \"npm run ws-server\" \"npm run karma-jasmine:autoclose\"",
44-
"test-dist": "concurrently \"npm run tsc:w\" \"npm run ws-server\" \"karma start karma-dist-jasmine.conf.js\"",
44+
"test-dist": "concurrently \"npm run tsc:w\" \"npm run ws-server\" \"karma start ./test/karma/common/dist/karma-dist-jasmine.conf.js\"",
4545
"test-node": "gulp test/node",
4646
"test-bluebird": "gulp test/bluebird",
47-
"test-mocha": "npm run tsc && concurrently \"npm run tsc:w\" \"npm run ws-server\" \"karma start karma-build-mocha.conf.js\"",
48-
"test-mocha-jasmine-bridge-browser": "npm run tsc && concurrently \"npm run ws-server\" \"karma start karma-build-mocha-jasmine-bridge.conf.js\"",
49-
"test-mocha-jasmine-bridge-node": "npm run tsc && mocha ./build/test/mocha/mocha-node-test-entry-point.js",
47+
"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\"",
48+
"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\"",
49+
"test-mocha-jasmine-bridge-node": "npm run tsc && mocha ./build/test/spec/mocha/mocha-node-test-entry-point.js",
5050
"serve": "python -m SimpleHTTPServer 8000"
5151
},
5252
"repository": {

0 commit comments

Comments
 (0)