-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add integration test for side effects
This new tests keeps track of the known side effects for Angular ES modules.
- Loading branch information
1 parent
4f9b167
commit ed74f92
Showing
23 changed files
with
984 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# The check-side-effects package generates and deletes this file. | ||
# If the process is killed, it will be left behind. | ||
check-side-effects.tmp-input.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
This test checks if the side effects for loading Angular packages have changed using <https://github.com/filipesilva/check-side-effects>. | ||
|
||
Running `yarn test` will check all ES modules listed in `side-effects.json`. | ||
|
||
Running `yarn update` will update any changed side effects. | ||
|
||
To add a new ES module to this test, add a new entry in `side-effects.json`. | ||
|
||
Usually the ESM and FESM should have the same output, but retained objects that were renamed during the flattening step will leave behind a different name. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "angular-side-effects", | ||
"version": "0.0.0", | ||
"license": "MIT", | ||
"scripts": { | ||
"test": "check-side-effects --test side-effects.json --pure-getters", | ||
"update": "yarn test --update" | ||
}, | ||
"dependencies": { | ||
"@angular/animations": "file:../../dist/packages-dist/animations", | ||
"@angular/common": "file:../../dist/packages-dist/common", | ||
"@angular/core": "file:../../dist/packages-dist/core", | ||
"@angular/elements": "file:../../dist/packages-dist/elements", | ||
"@angular/forms": "file:../../dist/packages-dist/forms", | ||
"@angular/platform-browser": "file:../../dist/packages-dist/platform-browser", | ||
"@angular/router": "file:../../dist/packages-dist/router", | ||
"check-side-effects": "file:../../node_modules/check-side-effects" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
{ | ||
"tests": [ | ||
{ | ||
"esModules": "./node_modules/@angular/animations/esm5/animations.js", | ||
"expectedOutput": "./snapshots/animations/esm5.js" | ||
}, | ||
{ | ||
"esModules": "./node_modules/@angular/animations/fesm5/animations.js", | ||
"expectedOutput": "./snapshots/animations/esm5.js" | ||
}, | ||
{ | ||
"esModules": "./node_modules/@angular/animations/esm2015/animations.js", | ||
"expectedOutput": "./snapshots/animations/esm2015.js" | ||
}, | ||
{ | ||
"esModules": "./node_modules/@angular/animations/fesm2015/animations.js", | ||
"expectedOutput": "./snapshots/animations/esm2015.js" | ||
}, | ||
{ | ||
"esModules": "./node_modules/@angular/animations/esm5/browser/browser.js", | ||
"expectedOutput": "./snapshots/animations-browser/esm5.js" | ||
}, | ||
{ | ||
"esModules": "./node_modules/@angular/animations/fesm5/browser.js", | ||
"expectedOutput": "./snapshots/animations-browser/esm5.js" | ||
}, | ||
{ | ||
"esModules": "./node_modules/@angular/animations/esm2015/browser/browser.js", | ||
"expectedOutput": "./snapshots/animations-browser/esm2015.js" | ||
}, | ||
{ | ||
"esModules": "./node_modules/@angular/animations/fesm2015/browser.js", | ||
"expectedOutput": "./snapshots/animations-browser/esm2015.js" | ||
}, | ||
{ | ||
"esModules": "./node_modules/@angular/common/esm5/common.js", | ||
"expectedOutput": "./snapshots/common/esm5.js" | ||
}, | ||
{ | ||
"esModules": "./node_modules/@angular/common/fesm5/common.js", | ||
"expectedOutput": "./snapshots/common/esm5.js" | ||
}, | ||
{ | ||
"esModules": "./node_modules/@angular/common/esm2015/common.js", | ||
"expectedOutput": "./snapshots/common/esm2015.js" | ||
}, | ||
{ | ||
"esModules": "./node_modules/@angular/common/fesm2015/common.js", | ||
"expectedOutput": "./snapshots/common/esm2015.js" | ||
}, | ||
{ | ||
"esModules": "./node_modules/@angular/core/esm5/core.js", | ||
"expectedOutput": "./snapshots/core/esm5.js" | ||
}, | ||
{ | ||
"esModules": "./node_modules/@angular/core/fesm5/core.js", | ||
"expectedOutput": "./snapshots/core/esm5.js" | ||
}, | ||
{ | ||
"esModules": "./node_modules/@angular/core/esm2015/core.js", | ||
"expectedOutput": "./snapshots/core/esm2015.js" | ||
}, | ||
{ | ||
"esModules": "./node_modules/@angular/core/fesm2015/core.js", | ||
"expectedOutput": "./snapshots/core/esm2015.js" | ||
}, | ||
{ | ||
"esModules": "./node_modules/@angular/elements/esm5/elements.js", | ||
"expectedOutput": "./snapshots/elements/esm5.js" | ||
}, | ||
{ | ||
"esModules": "./node_modules/@angular/elements/fesm5/elements.js", | ||
"expectedOutput": "./snapshots/elements/esm5.js" | ||
}, | ||
{ | ||
"esModules": "./node_modules/@angular/elements/esm2015/elements.js", | ||
"expectedOutput": "./snapshots/elements/esm2015.js" | ||
}, | ||
{ | ||
"esModules": "./node_modules/@angular/elements/fesm2015/elements.js", | ||
"expectedOutput": "./snapshots/elements/esm2015.js" | ||
}, | ||
{ | ||
"esModules": "./node_modules/@angular/forms/esm5/forms.js", | ||
"expectedOutput": "./snapshots/forms/esm5.js" | ||
}, | ||
{ | ||
"esModules": "./node_modules/@angular/forms/fesm5/forms.js", | ||
"expectedOutput": "./snapshots/forms/esm5.js" | ||
}, | ||
{ | ||
"esModules": "./node_modules/@angular/forms/esm2015/forms.js", | ||
"expectedOutput": "./snapshots/forms/esm2015.js" | ||
}, | ||
{ | ||
"esModules": "./node_modules/@angular/forms/fesm2015/forms.js", | ||
"expectedOutput": "./snapshots/forms/esm2015.js" | ||
}, | ||
{ | ||
"esModules": "./node_modules/@angular/platform-browser/esm5/platform-browser.js", | ||
"expectedOutput": "./snapshots/platform-browser/esm5.js" | ||
}, | ||
{ | ||
"esModules": "./node_modules/@angular/platform-browser/fesm5/platform-browser.js", | ||
"expectedOutput": "./snapshots/platform-browser/esm5.js" | ||
}, | ||
{ | ||
"esModules": "./node_modules/@angular/platform-browser/esm2015/platform-browser.js", | ||
"expectedOutput": "./snapshots/platform-browser/esm2015.js" | ||
}, | ||
{ | ||
"esModules": "./node_modules/@angular/platform-browser/fesm2015/platform-browser.js", | ||
"expectedOutput": "./snapshots/platform-browser/esm2015.js" | ||
}, | ||
{ | ||
"esModules": "./node_modules/@angular/router/esm5/router.js", | ||
"expectedOutput": "./snapshots/router/esm5.js" | ||
}, | ||
{ | ||
"esModules": "./node_modules/@angular/router/fesm5/router.js", | ||
"expectedOutput": "./snapshots/router/esm5.js" | ||
}, | ||
{ | ||
"esModules": "./node_modules/@angular/router/esm2015/router.js", | ||
"expectedOutput": "./snapshots/router/esm2015.js" | ||
}, | ||
{ | ||
"esModules": "./node_modules/@angular/router/fesm2015/router.js", | ||
"expectedOutput": "./snapshots/router/esm2015.js" | ||
} | ||
] | ||
} |
14 changes: 14 additions & 0 deletions
14
integration/side-effects/snapshots/animations-browser/esm2015.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import "@angular/animations"; | ||
|
||
import "@angular/core"; | ||
|
||
function isNode() { | ||
return "undefined" !== typeof process; | ||
} | ||
|
||
const _isNode = isNode(); | ||
|
||
if (_isNode || "undefined" !== typeof Element) if (_isNode || Element.prototype.matches) ; else { | ||
const proto = Element.prototype; | ||
const fn = proto.matchesSelector || proto.mozMatchesSelector || proto.msMatchesSelector || proto.oMatchesSelector || proto.webkitMatchesSelector; | ||
} |
16 changes: 16 additions & 0 deletions
16
integration/side-effects/snapshots/animations-browser/esm5.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import "tslib"; | ||
|
||
import "@angular/animations"; | ||
|
||
import "@angular/core"; | ||
|
||
function isNode() { | ||
return "undefined" !== typeof process; | ||
} | ||
|
||
var _isNode = isNode(); | ||
|
||
if (_isNode || "undefined" !== typeof Element) if (_isNode || Element.prototype.matches) ; else { | ||
var proto = Element.prototype; | ||
var fn_1 = proto.matchesSelector || proto.mozMatchesSelector || proto.msMatchesSelector || proto.oMatchesSelector || proto.webkitMatchesSelector; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import "@angular/core"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import "@angular/core"; | ||
|
||
import "tslib"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
import { Subject, Subscription } from "rxjs"; | ||
|
||
import "rxjs/operators"; | ||
|
||
function getGlobal() { | ||
const __globalThis = "undefined" !== typeof globalThis && globalThis; | ||
const __window = "undefined" !== typeof window && window; | ||
const __self = "undefined" !== typeof self && "undefined" !== typeof WorkerGlobalScope && self instanceof WorkerGlobalScope && self; | ||
const __global = "undefined" !== typeof global && global; | ||
return __globalThis || __global || __window || __self; | ||
} | ||
|
||
const _global = getGlobal(); | ||
|
||
let _symbolIterator = null; | ||
|
||
function getSymbolIterator() { | ||
if (!_symbolIterator) { | ||
const Symbol = _global["Symbol"]; | ||
if (Symbol && Symbol.iterator) _symbolIterator = Symbol.iterator; else { | ||
const keys = Object.getOwnPropertyNames(Map.prototype); | ||
for (let i = 0; i < keys.length; ++i) { | ||
const key = keys[i]; | ||
if ("entries" !== key && "size" !== key && Map.prototype[key] === Map.prototype["entries"]) _symbolIterator = key; | ||
} | ||
} | ||
} | ||
return _symbolIterator; | ||
} | ||
|
||
if ("undefined" === typeof ngI18nClosureMode) _global["ngI18nClosureMode"] = "undefined" !== typeof goog && "function" === typeof goog.getMsg; | ||
|
||
function flatten(list, mapFn) { | ||
const result = []; | ||
let i = 0; | ||
while (i < list.length) { | ||
const item = list[i]; | ||
if (Array.isArray(item)) if (item.length > 0) { | ||
list = item.concat(list.slice(i + 1)); | ||
i = 0; | ||
} else i++; else { | ||
result.push(mapFn ? mapFn(item) : item); | ||
i++; | ||
} | ||
} | ||
return result; | ||
} | ||
|
||
class EventEmitter extends Subject { | ||
constructor(isAsync = false) { | ||
super(); | ||
this.__isAsync = isAsync; | ||
} | ||
emit(value) { | ||
super.next(value); | ||
} | ||
subscribe(generatorOrNext, error, complete) { | ||
let schedulerFn; | ||
let errorFn = err => null; | ||
let completeFn = () => null; | ||
if (generatorOrNext && "object" === typeof generatorOrNext) { | ||
schedulerFn = this.__isAsync ? value => { | ||
setTimeout(() => generatorOrNext.next(value)); | ||
} : value => { | ||
generatorOrNext.next(value); | ||
}; | ||
if (generatorOrNext.error) errorFn = this.__isAsync ? err => { | ||
setTimeout(() => generatorOrNext.error(err)); | ||
} : err => { | ||
generatorOrNext.error(err); | ||
}; | ||
if (generatorOrNext.complete) completeFn = this.__isAsync ? () => { | ||
setTimeout(() => generatorOrNext.complete()); | ||
} : () => { | ||
generatorOrNext.complete(); | ||
}; | ||
} else { | ||
schedulerFn = this.__isAsync ? value => { | ||
setTimeout(() => generatorOrNext(value)); | ||
} : value => { | ||
generatorOrNext(value); | ||
}; | ||
if (error) errorFn = this.__isAsync ? err => { | ||
setTimeout(() => error(err)); | ||
} : err => { | ||
error(err); | ||
}; | ||
if (complete) completeFn = this.__isAsync ? () => { | ||
setTimeout(() => complete()); | ||
} : () => { | ||
complete(); | ||
}; | ||
} | ||
const sink = super.subscribe(schedulerFn, errorFn, completeFn); | ||
if (generatorOrNext instanceof Subscription) generatorOrNext.add(sink); | ||
return sink; | ||
} | ||
} | ||
|
||
class QueryList { | ||
constructor() { | ||
this.dirty = true; | ||
this._results = []; | ||
this.changes = new EventEmitter(); | ||
this.length = 0; | ||
} | ||
map(fn) { | ||
return this._results.map(fn); | ||
} | ||
filter(fn) { | ||
return this._results.filter(fn); | ||
} | ||
find(fn) { | ||
return this._results.find(fn); | ||
} | ||
reduce(fn, init) { | ||
return this._results.reduce(fn, init); | ||
} | ||
forEach(fn) { | ||
this._results.forEach(fn); | ||
} | ||
some(fn) { | ||
return this._results.some(fn); | ||
} | ||
toArray() { | ||
return this._results.slice(); | ||
} | ||
[getSymbolIterator()]() { | ||
return this._results[getSymbolIterator()](); | ||
} | ||
toString() { | ||
return this._results.toString(); | ||
} | ||
reset(resultsTree) { | ||
this._results = flatten(resultsTree); | ||
this.dirty = false; | ||
this.length = this._results.length; | ||
this.last = this._results[this.length - 1]; | ||
this.first = this._results[0]; | ||
} | ||
notifyOnChanges() { | ||
this.changes.emit(this); | ||
} | ||
setDirty() { | ||
this.dirty = true; | ||
} | ||
destroy() { | ||
this.changes.complete(); | ||
this.changes.unsubscribe(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import "tslib"; | ||
|
||
import "rxjs"; | ||
|
||
import "rxjs/operators"; | ||
|
||
function getGlobal() { | ||
var __globalThis = "undefined" !== typeof globalThis && globalThis; | ||
var __window = "undefined" !== typeof window && window; | ||
var __self = "undefined" !== typeof self && "undefined" !== typeof WorkerGlobalScope && self instanceof WorkerGlobalScope && self; | ||
var __global = "undefined" !== typeof global && global; | ||
return __globalThis || __global || __window || __self; | ||
} | ||
|
||
var _global = getGlobal(); | ||
|
||
if ("undefined" === typeof ngI18nClosureMode) _global["ngI18nClosureMode"] = "undefined" !== typeof goog && "function" === typeof goog.getMsg; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import "@angular/core"; | ||
|
||
import "rxjs"; | ||
|
||
import "rxjs/operators"; | ||
|
||
const elProto = Element.prototype; | ||
|
||
const matches = elProto.matches || elProto.matchesSelector || elProto.mozMatchesSelector || elProto.msMatchesSelector || elProto.oMatchesSelector || elProto.webkitMatchesSelector; |
Oops, something went wrong.