fix(zone.js): add issue numbers of `@types/jasmine` to the test cases (#34625)
Some cases will still need to use `spy as any` cast, because `@types/jasmine` have some issues, 1. The issue jasmine doesn't handle optional method properties, https://github.com/DefinitelyTyped/DefinitelyTyped/issues/43486 2. The issue jasmine doesn't handle overload method correctly, https://github.com/DefinitelyTyped/DefinitelyTyped/issues/42455 PR Close #34625
This commit is contained in:
parent
ef4736d052
commit
41667de778
|
@ -29,8 +29,8 @@ const XSSI_PREFIX = ')]}\'\n';
|
||||||
|
|
||||||
{
|
{
|
||||||
describe('XhrBackend', () => {
|
describe('XhrBackend', () => {
|
||||||
let factory: MockXhrFactory = null !;
|
let factory: MockXhrFactory = null!;
|
||||||
let backend: HttpXhrBackend = null !;
|
let backend: HttpXhrBackend = null!;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
factory = new MockXhrFactory();
|
factory = new MockXhrFactory();
|
||||||
backend = new HttpXhrBackend(factory);
|
backend = new HttpXhrBackend(factory);
|
||||||
|
@ -92,7 +92,7 @@ const XSSI_PREFIX = ')]}\'\n';
|
||||||
factory.mock.mockFlush(200, 'OK', JSON.stringify({data: 'some data'}));
|
factory.mock.mockFlush(200, 'OK', JSON.stringify({data: 'some data'}));
|
||||||
expect(events.length).toBe(2);
|
expect(events.length).toBe(2);
|
||||||
const res = events[1] as HttpResponse<{data: string}>;
|
const res = events[1] as HttpResponse<{data: string}>;
|
||||||
expect(res.body !.data).toBe('some data');
|
expect(res.body!.data).toBe('some data');
|
||||||
});
|
});
|
||||||
it('handles a blank json response', () => {
|
it('handles a blank json response', () => {
|
||||||
const events = trackEvents(backend.handle(TEST_POST.clone({responseType: 'json'})));
|
const events = trackEvents(backend.handle(TEST_POST.clone({responseType: 'json'})));
|
||||||
|
@ -106,14 +106,14 @@ const XSSI_PREFIX = ')]}\'\n';
|
||||||
factory.mock.mockFlush(500, 'Error', JSON.stringify({data: 'some data'}));
|
factory.mock.mockFlush(500, 'Error', JSON.stringify({data: 'some data'}));
|
||||||
expect(events.length).toBe(2);
|
expect(events.length).toBe(2);
|
||||||
const res = events[1] as any as HttpErrorResponse;
|
const res = events[1] as any as HttpErrorResponse;
|
||||||
expect(res.error !.data).toBe('some data');
|
expect(res.error!.data).toBe('some data');
|
||||||
});
|
});
|
||||||
it('handles a json error response with XSSI prefix', () => {
|
it('handles a json error response with XSSI prefix', () => {
|
||||||
const events = trackEvents(backend.handle(TEST_POST.clone({responseType: 'json'})));
|
const events = trackEvents(backend.handle(TEST_POST.clone({responseType: 'json'})));
|
||||||
factory.mock.mockFlush(500, 'Error', XSSI_PREFIX + JSON.stringify({data: 'some data'}));
|
factory.mock.mockFlush(500, 'Error', XSSI_PREFIX + JSON.stringify({data: 'some data'}));
|
||||||
expect(events.length).toBe(2);
|
expect(events.length).toBe(2);
|
||||||
const res = events[1] as any as HttpErrorResponse;
|
const res = events[1] as any as HttpErrorResponse;
|
||||||
expect(res.error !.data).toBe('some data');
|
expect(res.error!.data).toBe('some data');
|
||||||
});
|
});
|
||||||
it('handles a json string response', () => {
|
it('handles a json string response', () => {
|
||||||
const events = trackEvents(backend.handle(TEST_POST.clone({responseType: 'json'})));
|
const events = trackEvents(backend.handle(TEST_POST.clone({responseType: 'json'})));
|
||||||
|
@ -128,7 +128,7 @@ const XSSI_PREFIX = ')]}\'\n';
|
||||||
factory.mock.mockFlush(200, 'OK', XSSI_PREFIX + JSON.stringify({data: 'some data'}));
|
factory.mock.mockFlush(200, 'OK', XSSI_PREFIX + JSON.stringify({data: 'some data'}));
|
||||||
expect(events.length).toBe(2);
|
expect(events.length).toBe(2);
|
||||||
const res = events[1] as HttpResponse<{data: string}>;
|
const res = events[1] as HttpResponse<{data: string}>;
|
||||||
expect(res.body !.data).toBe('some data');
|
expect(res.body!.data).toBe('some data');
|
||||||
});
|
});
|
||||||
it('emits unsuccessful responses via the error path', done => {
|
it('emits unsuccessful responses via the error path', done => {
|
||||||
backend.handle(TEST_POST).subscribe(undefined, (err: HttpErrorResponse) => {
|
backend.handle(TEST_POST).subscribe(undefined, (err: HttpErrorResponse) => {
|
||||||
|
|
|
@ -38,7 +38,7 @@ runInEachFileSystem(() => {
|
||||||
initMockFileSystem(fs, testFiles);
|
initMockFileSystem(fs, testFiles);
|
||||||
|
|
||||||
// Force single-process execution in unit tests by mocking available CPUs to 1.
|
// Force single-process execution in unit tests by mocking available CPUs to 1.
|
||||||
spyOn(os, 'cpus').and.returnValue([{ model: 'Mock CPU' } as any]);
|
spyOn(os, 'cpus').and.returnValue([{model: 'Mock CPU'} as any]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should run ngcc without errors for esm2015', () => {
|
it('should run ngcc without errors for esm2015', () => {
|
||||||
|
|
|
@ -13,6 +13,7 @@ describe('unlocker', () => {
|
||||||
spyOn(process, 'on');
|
spyOn(process, 'on');
|
||||||
require('../../../src/locking/lock_file_with_child_process/unlocker');
|
require('../../../src/locking/lock_file_with_child_process/unlocker');
|
||||||
// TODO: @JiaLiPassion, need to wait for @types/jasmine to handle the override case
|
// TODO: @JiaLiPassion, need to wait for @types/jasmine to handle the override case
|
||||||
|
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/42455
|
||||||
expect(process.on).toHaveBeenCalledWith('disconnect' as any, jasmine.any(Function));
|
expect(process.on).toHaveBeenCalledWith('disconnect' as any, jasmine.any(Function));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -47,7 +47,7 @@ describe('CachedFileSystem', () => {
|
||||||
let lstatSpy: jasmine.Spy;
|
let lstatSpy: jasmine.Spy;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
// For most of the tests the files are not symbolic links.
|
// For most of the tests the files are not symbolic links.
|
||||||
lstatSpy = spyOn(delegate, 'lstat').and.returnValue({ isSymbolicLink: () => false } as any);
|
lstatSpy = spyOn(delegate, 'lstat').and.returnValue({isSymbolicLink: () => false} as any);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call delegate if not in cache', () => {
|
it('should call delegate if not in cache', () => {
|
||||||
|
@ -93,7 +93,7 @@ describe('CachedFileSystem', () => {
|
||||||
describe('invalidateCaches()', () => {
|
describe('invalidateCaches()', () => {
|
||||||
it('should call the delegate `readFile()` if the path for the cached file has been invalidated',
|
it('should call the delegate `readFile()` if the path for the cached file has been invalidated',
|
||||||
() => {
|
() => {
|
||||||
spyOn(delegate, 'lstat').and.returnValue({ isSymbolicLink: () => false } as any);
|
spyOn(delegate, 'lstat').and.returnValue({isSymbolicLink: () => false} as any);
|
||||||
const spy = spyOn(delegate, 'readFile').and.returnValue('Some contents');
|
const spy = spyOn(delegate, 'readFile').and.returnValue('Some contents');
|
||||||
fs.readFile(abcPath); // Call once to fill the cache
|
fs.readFile(abcPath); // Call once to fill the cache
|
||||||
spy.calls.reset();
|
spy.calls.reset();
|
||||||
|
@ -230,7 +230,7 @@ describe('CachedFileSystem', () => {
|
||||||
describe('moveFile()', () => {
|
describe('moveFile()', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
// `moveFile()` relies upon `readFile` which calls through to `lstat()`, so stub it out.
|
// `moveFile()` relies upon `readFile` which calls through to `lstat()`, so stub it out.
|
||||||
spyOn(delegate, 'lstat').and.returnValue({ isSymbolicLink: () => false } as any);
|
spyOn(delegate, 'lstat').and.returnValue({isSymbolicLink: () => false} as any);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call delegate', () => {
|
it('should call delegate', () => {
|
||||||
|
|
|
@ -69,6 +69,7 @@ describe('NodeJSFileSystem', () => {
|
||||||
const result = fs.readdir(abcPath);
|
const result = fs.readdir(abcPath);
|
||||||
expect(result).toEqual([relativeFrom('x'), relativeFrom('y/z')]);
|
expect(result).toEqual([relativeFrom('x'), relativeFrom('y/z')]);
|
||||||
// TODO: @JiaLiPassion need to wait for @types/jasmine update to handle optional parameters.
|
// TODO: @JiaLiPassion need to wait for @types/jasmine update to handle optional parameters.
|
||||||
|
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/43486
|
||||||
expect(spy as any).toHaveBeenCalledWith(abcPath);
|
expect(spy as any).toHaveBeenCalledWith(abcPath);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -90,6 +91,7 @@ describe('NodeJSFileSystem', () => {
|
||||||
const result = fs.stat(abcPath);
|
const result = fs.stat(abcPath);
|
||||||
expect(result).toBe(stats);
|
expect(result).toBe(stats);
|
||||||
// TODO: @JiaLiPassion need to wait for @types/jasmine update to handle optional parameters.
|
// TODO: @JiaLiPassion need to wait for @types/jasmine update to handle optional parameters.
|
||||||
|
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/43486
|
||||||
expect(spy as any).toHaveBeenCalledWith(abcPath);
|
expect(spy as any).toHaveBeenCalledWith(abcPath);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -173,12 +175,14 @@ describe('NodeJSFileSystem', () => {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
spyOn(fs, 'stat').and.returnValue({ isDirectory: () => true } as any);
|
spyOn(fs, 'stat').and.returnValue({isDirectory: () => true} as any);
|
||||||
const mkdirSyncSpy = spyOn(realFs, 'mkdirSync').and.callFake(((path: string) => {
|
const mkdirSyncSpy =
|
||||||
if (path === abcPath) {
|
spyOn(realFs, 'mkdirSync').and.callFake(((path: string) => {
|
||||||
throw new Error('It exists already. Supposedly.');
|
if (path === abcPath) {
|
||||||
}
|
throw new Error(
|
||||||
}) as any);
|
'It exists already. Supposedly.');
|
||||||
|
}
|
||||||
|
}) as any);
|
||||||
|
|
||||||
fs.ensureDir(abcPath);
|
fs.ensureDir(abcPath);
|
||||||
expect(mkdirSyncSpy).toHaveBeenCalledTimes(3);
|
expect(mkdirSyncSpy).toHaveBeenCalledTimes(3);
|
||||||
|
@ -188,11 +192,12 @@ describe('NodeJSFileSystem', () => {
|
||||||
|
|
||||||
it('should fail if creating the directory throws and the directory does not exist', () => {
|
it('should fail if creating the directory throws and the directory does not exist', () => {
|
||||||
spyOn(fs, 'exists').and.returnValue(false);
|
spyOn(fs, 'exists').and.returnValue(false);
|
||||||
spyOn(realFs, 'mkdirSync').and.callFake(((path: string) => {
|
spyOn(realFs, 'mkdirSync')
|
||||||
if (path === abcPath) {
|
.and.callFake(((path: string) => {
|
||||||
throw new Error('Unable to create directory (for whatever reason).');
|
if (path === abcPath) {
|
||||||
}
|
throw new Error('Unable to create directory (for whatever reason).');
|
||||||
}) as any);
|
}
|
||||||
|
}) as any);
|
||||||
|
|
||||||
expect(() => fs.ensureDir(abcPath))
|
expect(() => fs.ensureDir(abcPath))
|
||||||
.toThrowError('Unable to create directory (for whatever reason).');
|
.toThrowError('Unable to create directory (for whatever reason).');
|
||||||
|
@ -212,12 +217,12 @@ describe('NodeJSFileSystem', () => {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
spyOn(fs, 'stat').and.returnValue({ isDirectory: isDirectorySpy } as any);
|
spyOn(fs, 'stat').and.returnValue({isDirectory: isDirectorySpy} as any);
|
||||||
spyOn(realFs, 'mkdirSync').and.callFake(((path: string) => {
|
spyOn(realFs, 'mkdirSync').and.callFake(((path: string) => {
|
||||||
if (path === abcPath) {
|
if (path === abcPath) {
|
||||||
throw new Error('It exists already. Supposedly.');
|
throw new Error('It exists already. Supposedly.');
|
||||||
}
|
}
|
||||||
}) as any);
|
}) as any);
|
||||||
|
|
||||||
expect(() => fs.ensureDir(abcPath)).toThrowError('It exists already. Supposedly.');
|
expect(() => fs.ensureDir(abcPath)).toThrowError('It exists already. Supposedly.');
|
||||||
expect(isDirectorySpy).toHaveBeenCalledTimes(1);
|
expect(isDirectorySpy).toHaveBeenCalledTimes(1);
|
||||||
|
|
|
@ -41,7 +41,9 @@ describe('ngc transformer command-line', () => {
|
||||||
basePath = support.basePath;
|
basePath = support.basePath;
|
||||||
outDir = path.join(basePath, 'built');
|
outDir = path.join(basePath, 'built');
|
||||||
process.chdir(basePath);
|
process.chdir(basePath);
|
||||||
write = (fileName: string, content: string) => { support.write(fileName, content); };
|
write = (fileName: string, content: string) => {
|
||||||
|
support.write(fileName, content);
|
||||||
|
};
|
||||||
|
|
||||||
write('tsconfig-base.json', `{
|
write('tsconfig-base.json', `{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
@ -96,8 +98,9 @@ describe('ngc transformer command-line', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('errors', () => {
|
describe('errors', () => {
|
||||||
|
beforeEach(() => {
|
||||||
beforeEach(() => { errorSpy.and.stub(); });
|
errorSpy.and.stub();
|
||||||
|
});
|
||||||
|
|
||||||
it('should not print the stack trace if user input file does not exist', () => {
|
it('should not print the stack trace if user input file does not exist', () => {
|
||||||
writeConfig(`{
|
writeConfig(`{
|
||||||
|
@ -231,7 +234,6 @@ describe('ngc transformer command-line', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('compile ngfactory files', () => {
|
describe('compile ngfactory files', () => {
|
||||||
|
|
||||||
it('should compile ngfactory files that are not referenced by root files', () => {
|
it('should compile ngfactory files that are not referenced by root files', () => {
|
||||||
writeConfig(`{
|
writeConfig(`{
|
||||||
"extends": "./tsconfig-base.json",
|
"extends": "./tsconfig-base.json",
|
||||||
|
@ -1122,7 +1124,6 @@ describe('ngc transformer command-line', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('with external symbol re-exports enabled', () => {
|
describe('with external symbol re-exports enabled', () => {
|
||||||
|
|
||||||
it('should be able to compile multiple libraries with summaries', () => {
|
it('should be able to compile multiple libraries with summaries', () => {
|
||||||
// Note: we need to emit the generated code for the libraries
|
// Note: we need to emit the generated code for the libraries
|
||||||
// into the node_modules, as that is the only way that we
|
// into the node_modules, as that is the only way that we
|
||||||
|
@ -1560,11 +1561,13 @@ describe('ngc transformer command-line', () => {
|
||||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
|
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
|
||||||
const timerToken = 100;
|
const timerToken = 100;
|
||||||
// TODO: @JiaLiPassion, need to wait @types/jasmine to handle optional method case
|
// TODO: @JiaLiPassion, need to wait @types/jasmine to handle optional method case
|
||||||
|
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/43486
|
||||||
spyOn(ts.sys as any, 'setTimeout').and.callFake((callback: () => void) => {
|
spyOn(ts.sys as any, 'setTimeout').and.callFake((callback: () => void) => {
|
||||||
timer = callback;
|
timer = callback;
|
||||||
return timerToken;
|
return timerToken;
|
||||||
});
|
});
|
||||||
// TODO: @JiaLiPassion, need to wait @types/jasmine to handle optional method case
|
// TODO: @JiaLiPassion, need to wait @types/jasmine to handle optional method case
|
||||||
|
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/43486
|
||||||
spyOn(ts.sys as any, 'clearTimeout').and.callFake((token: number) => {
|
spyOn(ts.sys as any, 'clearTimeout').and.callFake((token: number) => {
|
||||||
if (token == timerToken) {
|
if (token == timerToken) {
|
||||||
timer = undefined;
|
timer = undefined;
|
||||||
|
@ -1617,7 +1620,9 @@ describe('ngc transformer command-line', () => {
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => { jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout; });
|
afterEach(() => {
|
||||||
|
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
||||||
|
});
|
||||||
|
|
||||||
function writeAppConfig(location: string) {
|
function writeAppConfig(location: string) {
|
||||||
writeConfig(`{
|
writeConfig(`{
|
||||||
|
@ -1672,11 +1677,13 @@ describe('ngc transformer command-line', () => {
|
||||||
`);
|
`);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should recompile when the html file changes',
|
it('should recompile when the html file changes', expectRecompile(() => {
|
||||||
expectRecompile(() => { write('greet.html', '<p> Hello {{name}} again!</p>'); }));
|
write('greet.html', '<p> Hello {{name}} again!</p>');
|
||||||
|
}));
|
||||||
|
|
||||||
it('should recompile when the css file changes',
|
it('should recompile when the css file changes', expectRecompile(() => {
|
||||||
expectRecompile(() => { write('greet.css', `p.greeting { color: blue }`); }));
|
write('greet.css', `p.greeting { color: blue }`);
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('regressions', () => {
|
describe('regressions', () => {
|
||||||
|
@ -2041,8 +2048,8 @@ describe('ngc transformer command-line', () => {
|
||||||
expect(exitCode).toBe(1, 'Compile was expected to fail');
|
expect(exitCode).toBe(1, 'Compile was expected to fail');
|
||||||
const srcPathWithSep = `lib/`;
|
const srcPathWithSep = `lib/`;
|
||||||
expect(messages[0])
|
expect(messages[0])
|
||||||
.toEqual(
|
.toEqual(`${
|
||||||
`${srcPathWithSep}test.component.ts(6,21): Error during template compile of 'TestComponent'
|
srcPathWithSep}test.component.ts(6,21): Error during template compile of 'TestComponent'
|
||||||
Tagged template expressions are not supported in metadata in 't1'
|
Tagged template expressions are not supported in metadata in 't1'
|
||||||
't1' references 't2' at ${srcPathWithSep}indirect1.ts(3,27)
|
't1' references 't2' at ${srcPathWithSep}indirect1.ts(3,27)
|
||||||
't2' contains the error at ${srcPathWithSep}indirect2.ts(4,27).
|
't2' contains the error at ${srcPathWithSep}indirect2.ts(4,27).
|
||||||
|
@ -2051,7 +2058,6 @@ describe('ngc transformer command-line', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('tree shakeable services', () => {
|
describe('tree shakeable services', () => {
|
||||||
|
|
||||||
function compileService(source: string): string {
|
function compileService(source: string): string {
|
||||||
write('service.ts', source);
|
write('service.ts', source);
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,8 @@ describe('convertValueToOutputAst', () => {
|
||||||
it('should convert all array elements, including undefined', () => {
|
it('should convert all array elements, including undefined', () => {
|
||||||
const ctx = null;
|
const ctx = null;
|
||||||
const value = new Array(3).concat('foo');
|
const value = new Array(3).concat('foo');
|
||||||
const expr = convertValueToOutputAst(ctx !, value) as o.LiteralArrayExpr;
|
const expr = convertValueToOutputAst(ctx!, value) as o.LiteralArrayExpr;
|
||||||
expect(expr instanceof o.LiteralArrayExpr);
|
expect(expr instanceof o.LiteralArrayExpr).toBe(true);
|
||||||
expect(expr.entries.length).toBe(4);
|
expect(expr.entries.length).toBe(4);
|
||||||
for (let i = 0; i < 4; ++i) {
|
for (let i = 0; i < 4; ++i) {
|
||||||
expect(expr.entries[i] instanceof o.Expression).toBe(true);
|
expect(expr.entries[i] instanceof o.Expression).toBe(true);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -25,26 +25,41 @@ describe('global utils', () => {
|
||||||
describe('publishDefaultGlobalUtils', () => {
|
describe('publishDefaultGlobalUtils', () => {
|
||||||
beforeEach(() => publishDefaultGlobalUtils());
|
beforeEach(() => publishDefaultGlobalUtils());
|
||||||
|
|
||||||
it('should publish getComponent', () => { assertPublished('getComponent', getComponent); });
|
it('should publish getComponent', () => {
|
||||||
|
assertPublished('getComponent', getComponent);
|
||||||
|
});
|
||||||
|
|
||||||
it('should publish getContext', () => { assertPublished('getContext', getContext); });
|
it('should publish getContext', () => {
|
||||||
|
assertPublished('getContext', getContext);
|
||||||
|
});
|
||||||
|
|
||||||
it('should publish getListeners', () => { assertPublished('getListeners', getListeners); });
|
it('should publish getListeners', () => {
|
||||||
|
assertPublished('getListeners', getListeners);
|
||||||
|
});
|
||||||
|
|
||||||
it('should publish getOwningComponent',
|
it('should publish getOwningComponent', () => {
|
||||||
() => { assertPublished('getOwningComponent', getOwningComponent); });
|
assertPublished('getOwningComponent', getOwningComponent);
|
||||||
|
});
|
||||||
|
|
||||||
it('should publish getRootComponents',
|
it('should publish getRootComponents', () => {
|
||||||
() => { assertPublished('getRootComponents', getRootComponents); });
|
assertPublished('getRootComponents', getRootComponents);
|
||||||
|
});
|
||||||
|
|
||||||
it('should publish getDirectives', () => { assertPublished('getDirectives', getDirectives); });
|
it('should publish getDirectives', () => {
|
||||||
|
assertPublished('getDirectives', getDirectives);
|
||||||
|
});
|
||||||
|
|
||||||
it('should publish getHostComponent',
|
it('should publish getHostComponent', () => {
|
||||||
() => { assertPublished('getHostElement', getHostElement); });
|
assertPublished('getHostElement', getHostElement);
|
||||||
|
});
|
||||||
|
|
||||||
it('should publish getInjector', () => { assertPublished('getInjector', getInjector); });
|
it('should publish getInjector', () => {
|
||||||
|
assertPublished('getInjector', getInjector);
|
||||||
|
});
|
||||||
|
|
||||||
it('should publish applyChanges', () => { assertPublished('applyChanges', applyChanges); });
|
it('should publish applyChanges', () => {
|
||||||
|
assertPublished('applyChanges', applyChanges);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -12,24 +12,21 @@ import {AttributeMarker, TAttributes, TNode, TNodeType} from '../../src/render3/
|
||||||
import {CssSelector, CssSelectorList, SelectorFlags} from '../../src/render3/interfaces/projection';
|
import {CssSelector, CssSelectorList, SelectorFlags} from '../../src/render3/interfaces/projection';
|
||||||
import {extractAttrsAndClassesFromSelector, getProjectAsAttrValue, isNodeMatchingSelector, isNodeMatchingSelectorList, stringifyCSSSelectorList} from '../../src/render3/node_selector_matcher';
|
import {extractAttrsAndClassesFromSelector, getProjectAsAttrValue, isNodeMatchingSelector, isNodeMatchingSelectorList, stringifyCSSSelectorList} from '../../src/render3/node_selector_matcher';
|
||||||
|
|
||||||
function testLStaticData(tagName: string, attrs: TAttributes | null): TNode {
|
function testLStaticData(tagName: string, attrs: TAttributes|null): TNode {
|
||||||
return createTNode(null !, null, TNodeType.Element, 0, tagName, attrs);
|
return createTNode(null!, null, TNodeType.Element, 0, tagName, attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('css selector matching', () => {
|
describe('css selector matching', () => {
|
||||||
function isMatching(
|
function isMatching(
|
||||||
tagName: string, attrsOrTNode: TAttributes | TNode | null, selector: CssSelector): boolean {
|
tagName: string, attrsOrTNode: TAttributes|TNode|null, selector: CssSelector): boolean {
|
||||||
const tNode = (!attrsOrTNode || Array.isArray(attrsOrTNode)) ?
|
const tNode = (!attrsOrTNode || Array.isArray(attrsOrTNode)) ?
|
||||||
createTNode(null !, null, TNodeType.Element, 0, tagName, attrsOrTNode as TAttributes) :
|
createTNode(null!, null, TNodeType.Element, 0, tagName, attrsOrTNode as TAttributes) :
|
||||||
(attrsOrTNode as TNode);
|
(attrsOrTNode as TNode);
|
||||||
return isNodeMatchingSelector(tNode, selector, true);
|
return isNodeMatchingSelector(tNode, selector, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('isNodeMatchingSimpleSelector', () => {
|
describe('isNodeMatchingSimpleSelector', () => {
|
||||||
|
|
||||||
|
|
||||||
describe('element matching', () => {
|
describe('element matching', () => {
|
||||||
|
|
||||||
it('should match element name only if names are the same', () => {
|
it('should match element name only if names are the same', () => {
|
||||||
expect(isMatching('span', null, ['span']))
|
expect(isMatching('span', null, ['span']))
|
||||||
.toBeTruthy(`Selector 'span' should match <span>`);
|
.toBeTruthy(`Selector 'span' should match <span>`);
|
||||||
|
@ -55,11 +52,9 @@ describe('css selector matching', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('attributes matching', () => {
|
describe('attributes matching', () => {
|
||||||
|
|
||||||
// TODO: do we need to differentiate no value and empty value? that is: title vs. title="" ?
|
// TODO: do we need to differentiate no value and empty value? that is: title vs. title="" ?
|
||||||
|
|
||||||
it('should match single attribute without value', () => {
|
it('should match single attribute without value', () => {
|
||||||
|
|
||||||
expect(isMatching('span', ['title', ''], [
|
expect(isMatching('span', ['title', ''], [
|
||||||
'', 'title', ''
|
'', 'title', ''
|
||||||
])).toBeTruthy(`Selector '[title]' should match <span title>`);
|
])).toBeTruthy(`Selector '[title]' should match <span title>`);
|
||||||
|
@ -81,7 +76,8 @@ describe('css selector matching', () => {
|
||||||
])).toBeFalsy(`Selector '[other]' should NOT match <span title="">'`);
|
])).toBeFalsy(`Selector '[other]' should NOT match <span title="">'`);
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: Not sure how to fix this cases.
|
// TODO: this case will not work, need more discussion
|
||||||
|
// https://github.com/angular/angular/pull/34625#discussion_r401791275
|
||||||
xit('should match namespaced attributes', () => {
|
xit('should match namespaced attributes', () => {
|
||||||
expect(isMatching(
|
expect(isMatching(
|
||||||
'span', [AttributeMarker.NamespaceURI, 'http://some/uri', 'title', 'name'],
|
'span', [AttributeMarker.NamespaceURI, 'http://some/uri', 'title', 'name'],
|
||||||
|
@ -228,7 +224,6 @@ describe('css selector matching', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('class matching', () => {
|
describe('class matching', () => {
|
||||||
|
|
||||||
it('should match with a class selector when an element has multiple classes', () => {
|
it('should match with a class selector when an element has multiple classes', () => {
|
||||||
expect(isMatching('span', ['class', 'foo bar'], [
|
expect(isMatching('span', ['class', 'foo bar'], [
|
||||||
'', SelectorFlags.CLASS, 'foo'
|
'', SelectorFlags.CLASS, 'foo'
|
||||||
|
@ -328,7 +323,6 @@ describe('css selector matching', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('negations', () => {
|
describe('negations', () => {
|
||||||
|
|
||||||
it('should match when negation part is null', () => {
|
it('should match when negation part is null', () => {
|
||||||
expect(isMatching('span', null, ['span'])).toBeTruthy(`Selector 'span' should match <span>`);
|
expect(isMatching('span', null, ['span'])).toBeTruthy(`Selector 'span' should match <span>`);
|
||||||
});
|
});
|
||||||
|
@ -436,13 +430,11 @@ describe('css selector matching', () => {
|
||||||
expect(isMatching('div', ['name', 'name', 'title', '', 'class', 'foo bar'], selector))
|
expect(isMatching('div', ['name', 'name', 'title', '', 'class', 'foo bar'], selector))
|
||||||
.toBeFalsy();
|
.toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('isNodeMatchingSelectorList', () => {
|
describe('isNodeMatchingSelectorList', () => {
|
||||||
|
|
||||||
function isAnyMatching(
|
function isAnyMatching(
|
||||||
tagName: string, attrs: string[] | null, selector: CssSelectorList): boolean {
|
tagName: string, attrs: string[]|null, selector: CssSelectorList): boolean {
|
||||||
return isNodeMatchingSelectorList(testLStaticData(tagName, attrs), selector, false);
|
return isNodeMatchingSelectorList(testLStaticData(tagName, attrs), selector, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -468,16 +460,18 @@ describe('css selector matching', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('reading the ngProjectAs attribute value', function() {
|
describe('reading the ngProjectAs attribute value', function() {
|
||||||
|
function testTNode(attrs: TAttributes|null) {
|
||||||
function testTNode(attrs: TAttributes | null) { return testLStaticData('tag', attrs); }
|
return testLStaticData('tag', attrs);
|
||||||
|
}
|
||||||
|
|
||||||
it('should get ngProjectAs value if present', function() {
|
it('should get ngProjectAs value if present', function() {
|
||||||
expect(getProjectAsAttrValue(testTNode([AttributeMarker.ProjectAs, ['tag', 'foo', 'bar']])))
|
expect(getProjectAsAttrValue(testTNode([AttributeMarker.ProjectAs, ['tag', 'foo', 'bar']])))
|
||||||
.toEqual(['tag', 'foo', 'bar']);
|
.toEqual(['tag', 'foo', 'bar']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return null if there are no attributes',
|
it('should return null if there are no attributes', function() {
|
||||||
function() { expect(getProjectAsAttrValue(testTNode(null))).toBe(null); });
|
expect(getProjectAsAttrValue(testTNode(null))).toBe(null);
|
||||||
|
});
|
||||||
|
|
||||||
it('should return if ngProjectAs is not present', function() {
|
it('should return if ngProjectAs is not present', function() {
|
||||||
expect(getProjectAsAttrValue(testTNode(['foo', 'bar']))).toBe(null);
|
expect(getProjectAsAttrValue(testTNode(['foo', 'bar']))).toBe(null);
|
||||||
|
@ -486,15 +480,13 @@ describe('css selector matching', () => {
|
||||||
it('should not accidentally identify ngProjectAs in attribute values', function() {
|
it('should not accidentally identify ngProjectAs in attribute values', function() {
|
||||||
expect(getProjectAsAttrValue(testTNode(['foo', AttributeMarker.ProjectAs]))).toBe(null);
|
expect(getProjectAsAttrValue(testTNode(['foo', AttributeMarker.ProjectAs]))).toBe(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('stringifyCSSSelectorList', () => {
|
describe('stringifyCSSSelectorList', () => {
|
||||||
|
it('should stringify selector with a tag name only', () => {
|
||||||
it('should stringify selector with a tag name only',
|
expect(stringifyCSSSelectorList([['button']])).toBe('button');
|
||||||
() => { expect(stringifyCSSSelectorList([['button']])).toBe('button'); });
|
});
|
||||||
|
|
||||||
it('should stringify selector with attributes', () => {
|
it('should stringify selector with attributes', () => {
|
||||||
expect(stringifyCSSSelectorList([['', 'id', '']])).toBe('[id]');
|
expect(stringifyCSSSelectorList([['', 'id', '']])).toBe('[id]');
|
||||||
|
|
|
@ -17,6 +17,7 @@ describe('utils', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
// TODO: @JiaLiPassion, need to wait @types/jasmine to fix the wrong return
|
// TODO: @JiaLiPassion, need to wait @types/jasmine to fix the wrong return
|
||||||
// type infer issue.
|
// type infer issue.
|
||||||
|
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/43486
|
||||||
setTimeoutSpy = spyOn(window, 'setTimeout').and.returnValue(42 as any);
|
setTimeoutSpy = spyOn(window, 'setTimeout').and.returnValue(42 as any);
|
||||||
clearTimeoutSpy = spyOn(window, 'clearTimeout');
|
clearTimeoutSpy = spyOn(window, 'clearTimeout');
|
||||||
});
|
});
|
||||||
|
@ -83,8 +84,9 @@ describe('utils', () => {
|
||||||
expect(camelToDashCase('foo1Bar2Baz3Qux4')).toBe('foo1-bar2-baz3-qux4');
|
expect(camelToDashCase('foo1Bar2Baz3Qux4')).toBe('foo1-bar2-baz3-qux4');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should keep existing dashes',
|
it('should keep existing dashes', () => {
|
||||||
() => { expect(camelToDashCase('fooBar-baz-Qux')).toBe('foo-bar-baz--qux'); });
|
expect(camelToDashCase('fooBar-baz-Qux')).toBe('foo-bar-baz--qux');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('createCustomEvent()', () => {
|
describe('createCustomEvent()', () => {
|
||||||
|
@ -99,7 +101,6 @@ describe('utils', () => {
|
||||||
expect(event.cancelable).toBe(false);
|
expect(event.cancelable).toBe(false);
|
||||||
expect(event.detail).toEqual(value);
|
expect(event.detail).toEqual(value);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('isElement()', () => {
|
describe('isElement()', () => {
|
||||||
|
@ -131,7 +132,7 @@ describe('utils', () => {
|
||||||
it('should return true for functions', () => {
|
it('should return true for functions', () => {
|
||||||
const obj = {foo: function() {}, bar: () => null, baz() {}};
|
const obj = {foo: function() {}, bar: () => null, baz() {}};
|
||||||
const fns = [
|
const fns = [
|
||||||
function(){},
|
function() {},
|
||||||
() => null,
|
() => null,
|
||||||
obj.foo,
|
obj.foo,
|
||||||
obj.bar,
|
obj.bar,
|
||||||
|
@ -182,7 +183,7 @@ describe('utils', () => {
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
li = div.querySelector('li') !;
|
li = div.querySelector('li')!;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return whether the element matches the selector', () => {
|
it('should return whether the element matches the selector', () => {
|
||||||
|
@ -218,7 +219,9 @@ describe('utils', () => {
|
||||||
];
|
];
|
||||||
|
|
||||||
values.forEach((v1, i) => {
|
values.forEach((v1, i) => {
|
||||||
values.forEach((v2, j) => { expect(strictEquals(v1, v2)).toBe(i === j); });
|
values.forEach((v2, j) => {
|
||||||
|
expect(strictEquals(v1, v2)).toBe(i === j);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Inject, ReflectiveInjector, forwardRef, resolveForwardRef} from '@angular/core';
|
import {forwardRef, Inject, ReflectiveInjector, resolveForwardRef} from '@angular/core';
|
||||||
|
|
||||||
{
|
{
|
||||||
describe('forwardRef examples', () => {
|
describe('forwardRef examples', () => {
|
||||||
|
@ -26,7 +26,9 @@ import {Inject, ReflectiveInjector, forwardRef, resolveForwardRef} from '@angula
|
||||||
|
|
||||||
// Door attempts to inject Lock, despite it not being defined yet.
|
// Door attempts to inject Lock, despite it not being defined yet.
|
||||||
// forwardRef makes this possible.
|
// forwardRef makes this possible.
|
||||||
constructor(@Inject(forwardRef(() => Lock)) lock: Lock) { this.lock = lock; }
|
constructor(@Inject(forwardRef(() => Lock)) lock: Lock) {
|
||||||
|
this.lock = lock;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only at this point Lock is defined.
|
// Only at this point Lock is defined.
|
||||||
|
|
|
@ -17,7 +17,9 @@ import {HammerGestureConfig, HammerGesturesPlugin,} from '@angular/platform-brow
|
||||||
let fakeConsole: any;
|
let fakeConsole: any;
|
||||||
if (isNode) return;
|
if (isNode) return;
|
||||||
|
|
||||||
beforeEach(() => { fakeConsole = {warn: jasmine.createSpy('console.warn')}; });
|
beforeEach(() => {
|
||||||
|
fakeConsole = {warn: jasmine.createSpy('console.warn')};
|
||||||
|
});
|
||||||
|
|
||||||
describe('with no custom loader', () => {
|
describe('with no custom loader', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@ -61,7 +63,9 @@ import {HammerGestureConfig, HammerGesturesPlugin,} from '@angular/platform-brow
|
||||||
// Inject the NgZone so that we can make it available to the plugin through a fake
|
// Inject the NgZone so that we can make it available to the plugin through a fake
|
||||||
// EventManager.
|
// EventManager.
|
||||||
let ngZone: NgZone;
|
let ngZone: NgZone;
|
||||||
beforeEach(inject([NgZone], (z: NgZone) => { ngZone = z; }));
|
beforeEach(inject([NgZone], (z: NgZone) => {
|
||||||
|
ngZone = z;
|
||||||
|
}));
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
originalHammerGlobal = (window as any).Hammer;
|
originalHammerGlobal = (window as any).Hammer;
|
||||||
|
@ -84,13 +88,15 @@ import {HammerGestureConfig, HammerGesturesPlugin,} from '@angular/platform-brow
|
||||||
plugin = new HammerGesturesPlugin(document, hammerConfig, fakeConsole, loader);
|
plugin = new HammerGesturesPlugin(document, hammerConfig, fakeConsole, loader);
|
||||||
|
|
||||||
// Use a fake EventManager that has access to the NgZone.
|
// Use a fake EventManager that has access to the NgZone.
|
||||||
plugin.manager = { getZone: () => ngZone } as EventManager;
|
plugin.manager = {getZone: () => ngZone} as EventManager;
|
||||||
|
|
||||||
someElement = document.createElement('div');
|
someElement = document.createElement('div');
|
||||||
someListener = () => {};
|
someListener = () => {};
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => { (window as any).Hammer = originalHammerGlobal; });
|
afterEach(() => {
|
||||||
|
(window as any).Hammer = originalHammerGlobal;
|
||||||
|
});
|
||||||
|
|
||||||
it('should not log a warning when HammerJS is not loaded', () => {
|
it('should not log a warning when HammerJS is not loaded', () => {
|
||||||
plugin.addEventListener(someElement, 'swipe', () => {});
|
plugin.addEventListener(someElement, 'swipe', () => {});
|
||||||
|
|
|
@ -51,7 +51,6 @@ import {KeyEventsPlugin} from '@angular/platform-browser/src/dom/events/key_even
|
||||||
.toEqual({'domEventName': 'keydown', 'fullKey': 'control.shift'});
|
.toEqual({'domEventName': 'keydown', 'fullKey': 'control.shift'});
|
||||||
expect(KeyEventsPlugin.parseEventName('keyup.control.shift'))
|
expect(KeyEventsPlugin.parseEventName('keyup.control.shift'))
|
||||||
.toEqual({'domEventName': 'keyup', 'fullKey': 'control.shift'});
|
.toEqual({'domEventName': 'keyup', 'fullKey': 'control.shift'});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should alias esc to escape', () => {
|
it('should alias esc to escape', () => {
|
||||||
|
@ -67,6 +66,5 @@ import {KeyEventsPlugin} from '@angular/platform-browser/src/dom/events/key_even
|
||||||
expect(() => plugin.addGlobalEventListener('window', 'keyup.control.esc', () => {}))
|
expect(() => plugin.addGlobalEventListener('window', 'keyup.control.esc', () => {}))
|
||||||
.not.toThrowError();
|
.not.toThrowError();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -3708,8 +3708,7 @@ describe('Integration', () => {
|
||||||
router.navigate(['/user/:fedor']);
|
router.navigate(['/user/:fedor']);
|
||||||
advance(fixture);
|
advance(fixture);
|
||||||
|
|
||||||
expect(navigateSpy.calls.mostRecent().args[1] !.queryParams);
|
expect(navigateSpy.calls.mostRecent().args[1]!.queryParams);
|
||||||
|
|
||||||
})));
|
})));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
import {PLATFORM_ID} from '@angular/core';
|
import {PLATFORM_ID} from '@angular/core';
|
||||||
import {TestBed} from '@angular/core/testing';
|
import {TestBed} from '@angular/core/testing';
|
||||||
import {NgswCommChannel} from '@angular/service-worker/src/low_level';
|
import {NgswCommChannel} from '@angular/service-worker/src/low_level';
|
||||||
import {SwRegistrationOptions, ngswCommChannelFactory} from '@angular/service-worker/src/module';
|
import {ngswCommChannelFactory, SwRegistrationOptions} from '@angular/service-worker/src/module';
|
||||||
import {SwPush} from '@angular/service-worker/src/push';
|
import {SwPush} from '@angular/service-worker/src/push';
|
||||||
import {SwUpdate} from '@angular/service-worker/src/update';
|
import {SwUpdate} from '@angular/service-worker/src/update';
|
||||||
import {MockPushManager, MockPushSubscription, MockServiceWorkerContainer, MockServiceWorkerRegistration, patchDecodeBase64} from '@angular/service-worker/testing/mock';
|
import {MockPushManager, MockPushSubscription, MockServiceWorkerContainer, MockServiceWorkerRegistration, patchDecodeBase64} from '@angular/service-worker/testing/mock';
|
||||||
|
@ -32,14 +32,18 @@ import {MockPushManager, MockPushSubscription, MockServiceWorkerContainer, MockS
|
||||||
|
|
||||||
mock.setupSw();
|
mock.setupSw();
|
||||||
|
|
||||||
(comm as any).registration.subscribe((reg: any) => { done(); });
|
(comm as any).registration.subscribe((reg: any) => {
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
it('can access the registration when it comes after subscription', done => {
|
it('can access the registration when it comes after subscription', done => {
|
||||||
const mock = new MockServiceWorkerContainer();
|
const mock = new MockServiceWorkerContainer();
|
||||||
const comm = new NgswCommChannel(mock as any);
|
const comm = new NgswCommChannel(mock as any);
|
||||||
const regPromise = mock.getRegistration() as any as MockServiceWorkerRegistration;
|
const regPromise = mock.getRegistration() as any as MockServiceWorkerRegistration;
|
||||||
|
|
||||||
(comm as any).registration.subscribe((reg: any) => { done(); });
|
(comm as any).registration.subscribe((reg: any) => {
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
mock.setupSw();
|
mock.setupSw();
|
||||||
});
|
});
|
||||||
|
@ -158,7 +162,7 @@ import {MockPushManager, MockPushSubscription, MockServiceWorkerContainer, MockS
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('requestSubscription()', () => {
|
describe('requestSubscription()', () => {
|
||||||
it('returns a promise that resolves to the subscription', async() => {
|
it('returns a promise that resolves to the subscription', async () => {
|
||||||
const promise = push.requestSubscription({serverPublicKey: 'test'});
|
const promise = push.requestSubscription({serverPublicKey: 'test'});
|
||||||
expect(promise).toEqual(jasmine.any(Promise));
|
expect(promise).toEqual(jasmine.any(Promise));
|
||||||
|
|
||||||
|
@ -166,7 +170,7 @@ import {MockPushManager, MockPushSubscription, MockServiceWorkerContainer, MockS
|
||||||
expect(sub).toEqual(jasmine.any(MockPushSubscription));
|
expect(sub).toEqual(jasmine.any(MockPushSubscription));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('calls `PushManager.subscribe()` (with appropriate options)', async() => {
|
it('calls `PushManager.subscribe()` (with appropriate options)', async () => {
|
||||||
const decode = (charCodeArr: Uint8Array) =>
|
const decode = (charCodeArr: Uint8Array) =>
|
||||||
Array.from(charCodeArr).map(c => String.fromCharCode(c)).join('');
|
Array.from(charCodeArr).map(c => String.fromCharCode(c)).join('');
|
||||||
|
|
||||||
|
@ -183,12 +187,12 @@ import {MockPushManager, MockPushSubscription, MockServiceWorkerContainer, MockS
|
||||||
userVisibleOnly: true,
|
userVisibleOnly: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const actualAppServerKey = pmSubscribeSpy.calls.first().args[0] !.applicationServerKey;
|
const actualAppServerKey = pmSubscribeSpy.calls.first().args[0]!.applicationServerKey;
|
||||||
const actualAppServerKeyStr = decode(actualAppServerKey as Uint8Array);
|
const actualAppServerKeyStr = decode(actualAppServerKey as Uint8Array);
|
||||||
expect(actualAppServerKeyStr).toBe(appServerKeyStr);
|
expect(actualAppServerKeyStr).toBe(appServerKeyStr);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('emits the new `PushSubscription` on `SwPush.subscription`', async() => {
|
it('emits the new `PushSubscription` on `SwPush.subscription`', async () => {
|
||||||
const subscriptionSpy = jasmine.createSpy('subscriptionSpy');
|
const subscriptionSpy = jasmine.createSpy('subscriptionSpy');
|
||||||
push.subscription.subscribe(subscriptionSpy);
|
push.subscription.subscribe(subscriptionSpy);
|
||||||
const sub = await push.requestSubscription({serverPublicKey: 'test'});
|
const sub = await push.requestSubscription({serverPublicKey: 'test'});
|
||||||
|
@ -204,7 +208,7 @@ import {MockPushManager, MockPushSubscription, MockServiceWorkerContainer, MockS
|
||||||
psUnsubscribeSpy = spyOn(MockPushSubscription.prototype, 'unsubscribe').and.callThrough();
|
psUnsubscribeSpy = spyOn(MockPushSubscription.prototype, 'unsubscribe').and.callThrough();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('rejects if currently not subscribed to push notifications', async() => {
|
it('rejects if currently not subscribed to push notifications', async () => {
|
||||||
try {
|
try {
|
||||||
await push.unsubscribe();
|
await push.unsubscribe();
|
||||||
throw new Error('`unsubscribe()` should fail');
|
throw new Error('`unsubscribe()` should fail');
|
||||||
|
@ -213,15 +217,17 @@ import {MockPushManager, MockPushSubscription, MockServiceWorkerContainer, MockS
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('calls `PushSubscription.unsubscribe()`', async() => {
|
it('calls `PushSubscription.unsubscribe()`', async () => {
|
||||||
await push.requestSubscription({serverPublicKey: 'test'});
|
await push.requestSubscription({serverPublicKey: 'test'});
|
||||||
await push.unsubscribe();
|
await push.unsubscribe();
|
||||||
|
|
||||||
expect(psUnsubscribeSpy).toHaveBeenCalledTimes(1);
|
expect(psUnsubscribeSpy).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('rejects if `PushSubscription.unsubscribe()` fails', async() => {
|
it('rejects if `PushSubscription.unsubscribe()` fails', async () => {
|
||||||
psUnsubscribeSpy.and.callFake(() => { throw new Error('foo'); });
|
psUnsubscribeSpy.and.callFake(() => {
|
||||||
|
throw new Error('foo');
|
||||||
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await push.requestSubscription({serverPublicKey: 'test'});
|
await push.requestSubscription({serverPublicKey: 'test'});
|
||||||
|
@ -232,7 +238,7 @@ import {MockPushManager, MockPushSubscription, MockServiceWorkerContainer, MockS
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('rejects if `PushSubscription.unsubscribe()` returns false', async() => {
|
it('rejects if `PushSubscription.unsubscribe()` returns false', async () => {
|
||||||
psUnsubscribeSpy.and.returnValue(Promise.resolve(false));
|
psUnsubscribeSpy.and.returnValue(Promise.resolve(false));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -244,7 +250,7 @@ import {MockPushManager, MockPushSubscription, MockServiceWorkerContainer, MockS
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('emits `null` on `SwPush.subscription`', async() => {
|
it('emits `null` on `SwPush.subscription`', async () => {
|
||||||
const subscriptionSpy = jasmine.createSpy('subscriptionSpy');
|
const subscriptionSpy = jasmine.createSpy('subscriptionSpy');
|
||||||
push.subscription.subscribe(subscriptionSpy);
|
push.subscription.subscribe(subscriptionSpy);
|
||||||
|
|
||||||
|
@ -254,7 +260,7 @@ import {MockPushManager, MockPushSubscription, MockServiceWorkerContainer, MockS
|
||||||
expect(subscriptionSpy).toHaveBeenCalledWith(null);
|
expect(subscriptionSpy).toHaveBeenCalledWith(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not emit on `SwPush.subscription` on failure', async() => {
|
it('does not emit on `SwPush.subscription` on failure', async () => {
|
||||||
const subscriptionSpy = jasmine.createSpy('subscriptionSpy');
|
const subscriptionSpy = jasmine.createSpy('subscriptionSpy');
|
||||||
const initialSubEmit = new Promise(resolve => subscriptionSpy.and.callFake(resolve));
|
const initialSubEmit = new Promise(resolve => subscriptionSpy.and.callFake(resolve));
|
||||||
|
|
||||||
|
@ -271,7 +277,9 @@ import {MockPushManager, MockPushSubscription, MockServiceWorkerContainer, MockS
|
||||||
subscriptionSpy.calls.reset();
|
subscriptionSpy.calls.reset();
|
||||||
|
|
||||||
// Error due to `PushSubscription.unsubscribe()` error.
|
// Error due to `PushSubscription.unsubscribe()` error.
|
||||||
psUnsubscribeSpy.and.callFake(() => { throw new Error('foo'); });
|
psUnsubscribeSpy.and.callFake(() => {
|
||||||
|
throw new Error('foo');
|
||||||
|
});
|
||||||
await push.unsubscribe().catch(() => undefined);
|
await push.unsubscribe().catch(() => undefined);
|
||||||
expect(subscriptionSpy).not.toHaveBeenCalled();
|
expect(subscriptionSpy).not.toHaveBeenCalled();
|
||||||
|
|
||||||
|
@ -338,7 +346,7 @@ import {MockPushManager, MockPushSubscription, MockServiceWorkerContainer, MockS
|
||||||
push.subscription.subscribe(subscriptionSpy);
|
push.subscription.subscribe(subscriptionSpy);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('emits on worker-driven changes (i.e. when the controller changes)', async() => {
|
it('emits on worker-driven changes (i.e. when the controller changes)', async () => {
|
||||||
// Initial emit for the current `ServiceWorkerController`.
|
// Initial emit for the current `ServiceWorkerController`.
|
||||||
await nextSubEmitPromise;
|
await nextSubEmitPromise;
|
||||||
expect(subscriptionSpy).toHaveBeenCalledTimes(1);
|
expect(subscriptionSpy).toHaveBeenCalledTimes(1);
|
||||||
|
@ -353,7 +361,7 @@ import {MockPushManager, MockPushSubscription, MockServiceWorkerContainer, MockS
|
||||||
expect(subscriptionSpy).toHaveBeenCalledWith(null);
|
expect(subscriptionSpy).toHaveBeenCalledWith(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('emits on subscription changes (i.e. when subscribing/unsubscribing)', async() => {
|
it('emits on subscription changes (i.e. when subscribing/unsubscribing)', async () => {
|
||||||
await nextSubEmitPromise;
|
await nextSubEmitPromise;
|
||||||
subscriptionSpy.calls.reset();
|
subscriptionSpy.calls.reset();
|
||||||
|
|
||||||
|
@ -391,11 +399,16 @@ import {MockPushManager, MockPushSubscription, MockServiceWorkerContainer, MockS
|
||||||
});
|
});
|
||||||
|
|
||||||
it('gives an error when registering', done => {
|
it('gives an error when registering', done => {
|
||||||
push.requestSubscription({serverPublicKey: 'test'}).catch(err => { done(); });
|
push.requestSubscription({serverPublicKey: 'test'}).catch(err => {
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('gives an error when unsubscribing',
|
it('gives an error when unsubscribing', done => {
|
||||||
done => { push.unsubscribe().catch(err => { done(); }); });
|
push.unsubscribe().catch(err => {
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -461,7 +474,9 @@ import {MockPushManager, MockPushSubscription, MockServiceWorkerContainer, MockS
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return update.activateUpdate()
|
return update.activateUpdate()
|
||||||
.catch(err => { expect(err.message).toEqual('Failed to activate'); })
|
.catch(err => {
|
||||||
|
expect(err.message).toEqual('Failed to activate');
|
||||||
|
})
|
||||||
.then(() => done())
|
.then(() => done())
|
||||||
.catch(err => done.fail(err));
|
.catch(err => done.fail(err));
|
||||||
});
|
});
|
||||||
|
@ -475,8 +490,12 @@ import {MockPushManager, MockPushSubscription, MockServiceWorkerContainer, MockS
|
||||||
expect(() => TestBed.inject(SwUpdate)).not.toThrow();
|
expect(() => TestBed.inject(SwUpdate)).not.toThrow();
|
||||||
});
|
});
|
||||||
describe('with no SW', () => {
|
describe('with no SW', () => {
|
||||||
beforeEach(() => { comm = new NgswCommChannel(undefined); });
|
beforeEach(() => {
|
||||||
it('can be instantiated', () => { update = new SwUpdate(comm); });
|
comm = new NgswCommChannel(undefined);
|
||||||
|
});
|
||||||
|
it('can be instantiated', () => {
|
||||||
|
update = new SwUpdate(comm);
|
||||||
|
});
|
||||||
it('does not crash on subscription to observables', () => {
|
it('does not crash on subscription to observables', () => {
|
||||||
update = new SwUpdate(comm);
|
update = new SwUpdate(comm);
|
||||||
update.available.toPromise().catch(err => fail(err));
|
update.available.toPromise().catch(err => fail(err));
|
||||||
|
@ -484,11 +503,15 @@ import {MockPushManager, MockPushSubscription, MockServiceWorkerContainer, MockS
|
||||||
});
|
});
|
||||||
it('gives an error when checking for updates', done => {
|
it('gives an error when checking for updates', done => {
|
||||||
update = new SwUpdate(comm);
|
update = new SwUpdate(comm);
|
||||||
update.checkForUpdate().catch(err => { done(); });
|
update.checkForUpdate().catch(err => {
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
it('gives an error when activating updates', done => {
|
it('gives an error when activating updates', done => {
|
||||||
update = new SwUpdate(comm);
|
update = new SwUpdate(comm);
|
||||||
update.activateUpdate().catch(err => { done(); });
|
update.activateUpdate().catch(err => {
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ApplicationRef, PLATFORM_ID} from '@angular/core';
|
import {ApplicationRef, PLATFORM_ID} from '@angular/core';
|
||||||
import {TestBed, fakeAsync, flushMicrotasks, tick} from '@angular/core/testing';
|
import {fakeAsync, flushMicrotasks, TestBed, tick} from '@angular/core/testing';
|
||||||
import {Subject} from 'rxjs';
|
import {Subject} from 'rxjs';
|
||||||
import {filter, take} from 'rxjs/operators';
|
import {filter, take} from 'rxjs/operators';
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ describe('ServiceWorkerModule', () => {
|
||||||
spyOn(navigator.serviceWorker, 'register').and.returnValue(Promise.resolve(null as any)));
|
spyOn(navigator.serviceWorker, 'register').and.returnValue(Promise.resolve(null as any)));
|
||||||
|
|
||||||
describe('register()', () => {
|
describe('register()', () => {
|
||||||
const configTestBed = async(opts: SwRegistrationOptions) => {
|
const configTestBed = async (opts: SwRegistrationOptions) => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [ServiceWorkerModule.register('sw.js', opts)],
|
imports: [ServiceWorkerModule.register('sw.js', opts)],
|
||||||
providers: [{provide: PLATFORM_ID, useValue: 'browser'}],
|
providers: [{provide: PLATFORM_ID, useValue: 'browser'}],
|
||||||
|
@ -42,35 +42,35 @@ describe('ServiceWorkerModule', () => {
|
||||||
await untilStable();
|
await untilStable();
|
||||||
};
|
};
|
||||||
|
|
||||||
it('sets the registration options', async() => {
|
it('sets the registration options', async () => {
|
||||||
await configTestBed({enabled: true, scope: 'foo'});
|
await configTestBed({enabled: true, scope: 'foo'});
|
||||||
|
|
||||||
expect(TestBed.inject(SwRegistrationOptions)).toEqual({enabled: true, scope: 'foo'});
|
expect(TestBed.inject(SwRegistrationOptions)).toEqual({enabled: true, scope: 'foo'});
|
||||||
expect(swRegisterSpy).toHaveBeenCalledWith('sw.js', {scope: 'foo'});
|
expect(swRegisterSpy).toHaveBeenCalledWith('sw.js', {scope: 'foo'});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can disable the SW', async() => {
|
it('can disable the SW', async () => {
|
||||||
await configTestBed({enabled: false});
|
await configTestBed({enabled: false});
|
||||||
|
|
||||||
expect(TestBed.inject(SwUpdate).isEnabled).toBe(false);
|
expect(TestBed.inject(SwUpdate).isEnabled).toBe(false);
|
||||||
expect(swRegisterSpy).not.toHaveBeenCalled();
|
expect(swRegisterSpy).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can enable the SW', async() => {
|
it('can enable the SW', async () => {
|
||||||
await configTestBed({enabled: true});
|
await configTestBed({enabled: true});
|
||||||
|
|
||||||
expect(TestBed.inject(SwUpdate).isEnabled).toBe(true);
|
expect(TestBed.inject(SwUpdate).isEnabled).toBe(true);
|
||||||
expect(swRegisterSpy).toHaveBeenCalledWith('sw.js', {scope: undefined});
|
expect(swRegisterSpy).toHaveBeenCalledWith('sw.js', {scope: undefined});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('defaults to enabling the SW', async() => {
|
it('defaults to enabling the SW', async () => {
|
||||||
await configTestBed({});
|
await configTestBed({});
|
||||||
|
|
||||||
expect(TestBed.inject(SwUpdate).isEnabled).toBe(true);
|
expect(TestBed.inject(SwUpdate).isEnabled).toBe(true);
|
||||||
expect(swRegisterSpy).toHaveBeenCalledWith('sw.js', {scope: undefined});
|
expect(swRegisterSpy).toHaveBeenCalledWith('sw.js', {scope: undefined});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('catches and a logs registration errors', async() => {
|
it('catches and a logs registration errors', async () => {
|
||||||
const consoleErrorSpy = spyOn(console, 'error');
|
const consoleErrorSpy = spyOn(console, 'error');
|
||||||
swRegisterSpy.and.returnValue(Promise.reject('no reason'));
|
swRegisterSpy.and.returnValue(Promise.reject('no reason'));
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ describe('ServiceWorkerModule', () => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
it('sets the registration options (and overwrites those set via `.register()`', async() => {
|
it('sets the registration options (and overwrites those set via `.register()`', async () => {
|
||||||
configTestBed({enabled: true, scope: 'provider'});
|
configTestBed({enabled: true, scope: 'provider'});
|
||||||
await untilStable();
|
await untilStable();
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ describe('ServiceWorkerModule', () => {
|
||||||
expect(swRegisterSpy).toHaveBeenCalledWith('sw.js', {scope: 'provider'});
|
expect(swRegisterSpy).toHaveBeenCalledWith('sw.js', {scope: 'provider'});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can disable the SW', async() => {
|
it('can disable the SW', async () => {
|
||||||
configTestBed({enabled: false}, {enabled: true});
|
configTestBed({enabled: false}, {enabled: true});
|
||||||
await untilStable();
|
await untilStable();
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ describe('ServiceWorkerModule', () => {
|
||||||
expect(swRegisterSpy).not.toHaveBeenCalled();
|
expect(swRegisterSpy).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can enable the SW', async() => {
|
it('can enable the SW', async () => {
|
||||||
configTestBed({enabled: true}, {enabled: false});
|
configTestBed({enabled: true}, {enabled: false});
|
||||||
await untilStable();
|
await untilStable();
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ describe('ServiceWorkerModule', () => {
|
||||||
expect(swRegisterSpy).toHaveBeenCalledWith('sw.js', {scope: undefined});
|
expect(swRegisterSpy).toHaveBeenCalledWith('sw.js', {scope: undefined});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('defaults to enabling the SW', async() => {
|
it('defaults to enabling the SW', async () => {
|
||||||
configTestBed({}, {enabled: false});
|
configTestBed({}, {enabled: false});
|
||||||
await untilStable();
|
await untilStable();
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -6,7 +6,7 @@
|
||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ChangeDetectorRef, Component, EventEmitter, Input, NO_ERRORS_SCHEMA, NgModule, NgModuleFactory, NgZone, OnChanges, OnDestroy, Output, SimpleChange, SimpleChanges, Testability, destroyPlatform, forwardRef} from '@angular/core';
|
import {ChangeDetectorRef, Component, destroyPlatform, EventEmitter, forwardRef, Input, NgModule, NgModuleFactory, NgZone, NO_ERRORS_SCHEMA, OnChanges, OnDestroy, Output, SimpleChange, SimpleChanges, Testability} from '@angular/core';
|
||||||
import {async, fakeAsync, flushMicrotasks, tick} from '@angular/core/testing';
|
import {async, fakeAsync, flushMicrotasks, tick} from '@angular/core/testing';
|
||||||
import {BrowserModule} from '@angular/platform-browser';
|
import {BrowserModule} from '@angular/platform-browser';
|
||||||
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
|
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
|
||||||
|
@ -23,7 +23,6 @@ declare global {
|
||||||
|
|
||||||
withEachNg1Version(() => {
|
withEachNg1Version(() => {
|
||||||
describe('adapter: ng1 to ng2', () => {
|
describe('adapter: ng1 to ng2', () => {
|
||||||
|
|
||||||
beforeEach(() => destroyPlatform());
|
beforeEach(() => destroyPlatform());
|
||||||
afterEach(() => destroyPlatform());
|
afterEach(() => destroyPlatform());
|
||||||
|
|
||||||
|
@ -232,7 +231,9 @@ withEachNg1Version(() => {
|
||||||
})
|
})
|
||||||
class Ng2 {
|
class Ng2 {
|
||||||
l: any;
|
l: any;
|
||||||
constructor() { this.l = l; }
|
constructor() {
|
||||||
|
this.l = l;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
@ -262,7 +263,9 @@ withEachNg1Version(() => {
|
||||||
@Component({selector: 'my-app', template: '<my-child [value]="value"></my-child>'})
|
@Component({selector: 'my-app', template: '<my-child [value]="value"></my-child>'})
|
||||||
class AppComponent {
|
class AppComponent {
|
||||||
value?: number;
|
value?: number;
|
||||||
constructor() { appComponent = this; }
|
constructor() {
|
||||||
|
appComponent = this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -272,7 +275,9 @@ withEachNg1Version(() => {
|
||||||
class ChildComponent {
|
class ChildComponent {
|
||||||
valueFromPromise?: number;
|
valueFromPromise?: number;
|
||||||
@Input()
|
@Input()
|
||||||
set value(v: number) { expect(NgZone.isInAngularZone()).toBe(true); }
|
set value(v: number) {
|
||||||
|
expect(NgZone.isInAngularZone()).toBe(true);
|
||||||
|
}
|
||||||
|
|
||||||
constructor(private zone: NgZone) {}
|
constructor(private zone: NgZone) {}
|
||||||
|
|
||||||
|
@ -352,14 +357,15 @@ withEachNg1Version(() => {
|
||||||
|
|
||||||
const element = html('<ng2></ng2>');
|
const element = html('<ng2></ng2>');
|
||||||
adapter.bootstrap(element, ['ng1']).ready((ref) => {
|
adapter.bootstrap(element, ['ng1']).ready((ref) => {
|
||||||
expect(multiTrim(document.body.textContent !)).toBe('It works');
|
expect(multiTrim(document.body.textContent!)).toBe('It works');
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should bind properties, events', async(() => {
|
it('should bind properties, events', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const ng1Module =
|
const ng1Module = angular.module_('ng1', []).value($EXCEPTION_HANDLER, (err: any) => {
|
||||||
angular.module_('ng1', []).value($EXCEPTION_HANDLER, (err: any) => { throw err; });
|
throw err;
|
||||||
|
});
|
||||||
|
|
||||||
ng1Module.run(($rootScope: any) => {
|
ng1Module.run(($rootScope: any) => {
|
||||||
$rootScope.name = 'world';
|
$rootScope.name = 'world';
|
||||||
|
@ -409,8 +415,8 @@ withEachNg1Version(() => {
|
||||||
}
|
}
|
||||||
const actValue = changes[prop].currentValue;
|
const actValue = changes[prop].currentValue;
|
||||||
if (actValue != value) {
|
if (actValue != value) {
|
||||||
throw new Error(
|
throw new Error(`Expected changes record for'${prop}' to be '${
|
||||||
`Expected changes record for'${prop}' to be '${value}' but was '${actValue}'`);
|
value}' but was '${actValue}'`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -458,7 +464,7 @@ withEachNg1Version(() => {
|
||||||
| modelA: {{modelA}}; modelB: {{modelB}}; eventA: {{eventA}}; eventB: {{eventB}};
|
| modelA: {{modelA}}; modelB: {{modelB}}; eventA: {{eventA}}; eventB: {{eventB}};
|
||||||
</div>`);
|
</div>`);
|
||||||
adapter.bootstrap(element, ['ng1']).ready((ref) => {
|
adapter.bootstrap(element, ['ng1']).ready((ref) => {
|
||||||
expect(multiTrim(document.body.textContent !))
|
expect(multiTrim(document.body.textContent!))
|
||||||
.toEqual(
|
.toEqual(
|
||||||
'ignore: -; ' +
|
'ignore: -; ' +
|
||||||
'literal: Text; interpolate: Hello world; ' +
|
'literal: Text; interpolate: Hello world; ' +
|
||||||
|
@ -466,7 +472,7 @@ withEachNg1Version(() => {
|
||||||
'modelA: newA; modelB: newB; eventA: aFired; eventB: bFired;');
|
'modelA: newA; modelB: newB; eventA: aFired; eventB: bFired;');
|
||||||
|
|
||||||
ref.ng1RootScope.$apply('name = "everyone"');
|
ref.ng1RootScope.$apply('name = "everyone"');
|
||||||
expect(multiTrim(document.body.textContent !))
|
expect(multiTrim(document.body.textContent!))
|
||||||
.toEqual(
|
.toEqual(
|
||||||
'ignore: -; ' +
|
'ignore: -; ' +
|
||||||
'literal: Text; interpolate: Hello everyone; ' +
|
'literal: Text; interpolate: Hello everyone; ' +
|
||||||
|
@ -475,7 +481,6 @@ withEachNg1Version(() => {
|
||||||
|
|
||||||
ref.dispose();
|
ref.dispose();
|
||||||
});
|
});
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should support two-way binding and event listener', async(() => {
|
it('should support two-way binding and event listener', async(() => {
|
||||||
|
@ -541,9 +546,9 @@ withEachNg1Version(() => {
|
||||||
ngOnChangesCount = 0;
|
ngOnChangesCount = 0;
|
||||||
firstChangesCount = 0;
|
firstChangesCount = 0;
|
||||||
// TODO(issue/24571): remove '!'.
|
// TODO(issue/24571): remove '!'.
|
||||||
initialValue !: string;
|
initialValue!: string;
|
||||||
// TODO(issue/24571): remove '!'.
|
// TODO(issue/24571): remove '!'.
|
||||||
@Input() foo !: string;
|
@Input() foo!: string;
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
this.ngOnChangesCount++;
|
this.ngOnChangesCount++;
|
||||||
|
@ -590,7 +595,9 @@ withEachNg1Version(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const ng1Module = angular.module_('ng1', []);
|
const ng1Module = angular.module_('ng1', []);
|
||||||
|
|
||||||
ng1Module.run(($rootScope: any /** TODO #9100 */) => { $rootScope.modelA = 'A'; });
|
ng1Module.run(($rootScope: any /** TODO #9100 */) => {
|
||||||
|
$rootScope.modelA = 'A';
|
||||||
|
});
|
||||||
|
|
||||||
let ng2Instance: Ng2;
|
let ng2Instance: Ng2;
|
||||||
@Component({selector: 'ng2', template: '{{_value}}'})
|
@Component({selector: 'ng2', template: '{{_value}}'})
|
||||||
|
@ -598,11 +605,21 @@ withEachNg1Version(() => {
|
||||||
private _value: any = '';
|
private _value: any = '';
|
||||||
private _onChangeCallback: (_: any) => void = () => {};
|
private _onChangeCallback: (_: any) => void = () => {};
|
||||||
private _onTouchedCallback: () => void = () => {};
|
private _onTouchedCallback: () => void = () => {};
|
||||||
constructor() { ng2Instance = this; }
|
constructor() {
|
||||||
writeValue(value: any) { this._value = value; }
|
ng2Instance = this;
|
||||||
registerOnChange(fn: any) { this._onChangeCallback = fn; }
|
}
|
||||||
registerOnTouched(fn: any) { this._onTouchedCallback = fn; }
|
writeValue(value: any) {
|
||||||
doTouch() { this._onTouchedCallback(); }
|
this._value = value;
|
||||||
|
}
|
||||||
|
registerOnChange(fn: any) {
|
||||||
|
this._onChangeCallback = fn;
|
||||||
|
}
|
||||||
|
registerOnTouched(fn: any) {
|
||||||
|
this._onTouchedCallback = fn;
|
||||||
|
}
|
||||||
|
doTouch() {
|
||||||
|
this._onTouchedCallback();
|
||||||
|
}
|
||||||
doChange(newValue: string) {
|
doChange(newValue: string) {
|
||||||
this._value = newValue;
|
this._value = newValue;
|
||||||
this._onChangeCallback(newValue);
|
this._onChangeCallback(newValue);
|
||||||
|
@ -653,14 +670,18 @@ withEachNg1Version(() => {
|
||||||
return {
|
return {
|
||||||
template: '<div ng-if="!destroyIt"><ng2></ng2></div>',
|
template: '<div ng-if="!destroyIt"><ng2></ng2></div>',
|
||||||
controller: function($rootScope: any, $timeout: Function) {
|
controller: function($rootScope: any, $timeout: Function) {
|
||||||
$timeout(() => { $rootScope.destroyIt = true; });
|
$timeout(() => {
|
||||||
|
$rootScope.destroyIt = true;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@Component({selector: 'ng2', template: 'test'})
|
@Component({selector: 'ng2', template: 'test'})
|
||||||
class Ng2 {
|
class Ng2 {
|
||||||
ngOnDestroy() { onDestroyed.emit('destroyed'); }
|
ngOnDestroy() {
|
||||||
|
onDestroyed.emit('destroyed');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
@ -673,7 +694,9 @@ withEachNg1Version(() => {
|
||||||
ng1Module.directive('ng2', adapter.downgradeNg2Component(Ng2));
|
ng1Module.directive('ng2', adapter.downgradeNg2Component(Ng2));
|
||||||
const element = html('<ng1></ng1>');
|
const element = html('<ng1></ng1>');
|
||||||
adapter.bootstrap(element, ['ng1']).ready((ref) => {
|
adapter.bootstrap(element, ['ng1']).ready((ref) => {
|
||||||
onDestroyed.subscribe(() => { ref.dispose(); });
|
onDestroyed.subscribe(() => {
|
||||||
|
ref.dispose();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -689,7 +712,9 @@ withEachNg1Version(() => {
|
||||||
|
|
||||||
@Component({selector: 'ng2-inner', template: 'test'})
|
@Component({selector: 'ng2-inner', template: 'test'})
|
||||||
class Ng2InnerComponent implements OnDestroy {
|
class Ng2InnerComponent implements OnDestroy {
|
||||||
ngOnDestroy() { destroyed = true; }
|
ngOnDestroy() {
|
||||||
|
destroyed = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
@ -789,7 +814,7 @@ withEachNg1Version(() => {
|
||||||
@Component({selector: 'ng2', template: 'ng2-{{ itemId }}(<ng-content></ng-content>)'})
|
@Component({selector: 'ng2', template: 'ng2-{{ itemId }}(<ng-content></ng-content>)'})
|
||||||
class Ng2Component {
|
class Ng2Component {
|
||||||
// TODO(issue/24571): remove '!'.
|
// TODO(issue/24571): remove '!'.
|
||||||
@Input() itemId !: string;
|
@Input() itemId!: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NgModule({imports: [BrowserModule], declarations: [Ng2Component]})
|
@NgModule({imports: [BrowserModule], declarations: [Ng2Component]})
|
||||||
|
@ -838,7 +863,7 @@ withEachNg1Version(() => {
|
||||||
ng1Module.directive('rootComponent', adapter.downgradeNg2Component(RootComponent));
|
ng1Module.directive('rootComponent', adapter.downgradeNg2Component(RootComponent));
|
||||||
|
|
||||||
document.body.innerHTML = '<root-component></root-component>';
|
document.body.innerHTML = '<root-component></root-component>';
|
||||||
adapter.bootstrap(document.body.firstElementChild !, ['myExample']).ready((ref) => {
|
adapter.bootstrap(document.body.firstElementChild!, ['myExample']).ready((ref) => {
|
||||||
expect(multiTrim(document.body.textContent)).toEqual('It works!');
|
expect(multiTrim(document.body.textContent)).toEqual('It works!');
|
||||||
ref.dispose();
|
ref.dispose();
|
||||||
});
|
});
|
||||||
|
@ -868,7 +893,9 @@ withEachNg1Version(() => {
|
||||||
dataA = 'foo';
|
dataA = 'foo';
|
||||||
dataB = 'bar';
|
dataB = 'bar';
|
||||||
|
|
||||||
constructor() { ng2ComponentInstance = this; }
|
constructor() {
|
||||||
|
ng2ComponentInstance = this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define `ng1Module`
|
// Define `ng1Module`
|
||||||
|
@ -888,8 +915,8 @@ withEachNg1Version(() => {
|
||||||
const element = html(`<ng2></ng2>`);
|
const element = html(`<ng2></ng2>`);
|
||||||
|
|
||||||
adapter.bootstrap(element, ['ng1Module']).ready(ref => {
|
adapter.bootstrap(element, ['ng1Module']).ready(ref => {
|
||||||
const ng1 = element.querySelector('ng1') !;
|
const ng1 = element.querySelector('ng1')!;
|
||||||
const ng1Controller = angular.element(ng1).controller !('ng1');
|
const ng1Controller = angular.element(ng1).controller!('ng1');
|
||||||
|
|
||||||
expect(multiTrim(element.textContent)).toBe('Inside: foo, bar | Outside: foo, bar');
|
expect(multiTrim(element.textContent)).toBe('Inside: foo, bar | Outside: foo, bar');
|
||||||
|
|
||||||
|
@ -932,7 +959,9 @@ withEachNg1Version(() => {
|
||||||
dataA = {value: 'foo'};
|
dataA = {value: 'foo'};
|
||||||
dataB = {value: 'bar'};
|
dataB = {value: 'bar'};
|
||||||
|
|
||||||
constructor() { ng2ComponentInstance = this; }
|
constructor() {
|
||||||
|
ng2ComponentInstance = this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define `ng1Module`
|
// Define `ng1Module`
|
||||||
|
@ -952,8 +981,8 @@ withEachNg1Version(() => {
|
||||||
const element = html(`<ng2></ng2>`);
|
const element = html(`<ng2></ng2>`);
|
||||||
|
|
||||||
adapter.bootstrap(element, ['ng1Module']).ready(ref => {
|
adapter.bootstrap(element, ['ng1Module']).ready(ref => {
|
||||||
const ng1 = element.querySelector('ng1') !;
|
const ng1 = element.querySelector('ng1')!;
|
||||||
const ng1Controller = angular.element(ng1).controller !('ng1');
|
const ng1Controller = angular.element(ng1).controller!('ng1');
|
||||||
|
|
||||||
expect(multiTrim(element.textContent)).toBe('Inside: foo, bar | Outside: foo, bar');
|
expect(multiTrim(element.textContent)).toBe('Inside: foo, bar | Outside: foo, bar');
|
||||||
|
|
||||||
|
@ -996,7 +1025,9 @@ withEachNg1Version(() => {
|
||||||
dataA = {value: 'foo'};
|
dataA = {value: 'foo'};
|
||||||
dataB = {value: 'bar'};
|
dataB = {value: 'bar'};
|
||||||
|
|
||||||
constructor() { ng2ComponentInstance = this; }
|
constructor() {
|
||||||
|
ng2ComponentInstance = this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define `ng1Module`
|
// Define `ng1Module`
|
||||||
|
@ -1016,8 +1047,8 @@ withEachNg1Version(() => {
|
||||||
const element = html(`<ng2></ng2>`);
|
const element = html(`<ng2></ng2>`);
|
||||||
|
|
||||||
adapter.bootstrap(element, ['ng1Module']).ready(ref => {
|
adapter.bootstrap(element, ['ng1Module']).ready(ref => {
|
||||||
const ng1 = element.querySelector('ng1') !;
|
const ng1 = element.querySelector('ng1')!;
|
||||||
const ng1Controller = angular.element(ng1).controller !('ng1');
|
const ng1Controller = angular.element(ng1).controller!('ng1');
|
||||||
|
|
||||||
expect(multiTrim(element.textContent)).toBe('Inside: foo, bar | Outside: foo, bar');
|
expect(multiTrim(element.textContent)).toBe('Inside: foo, bar | Outside: foo, bar');
|
||||||
|
|
||||||
|
@ -1077,8 +1108,8 @@ withEachNg1Version(() => {
|
||||||
const element = html(`<ng2></ng2>`);
|
const element = html(`<ng2></ng2>`);
|
||||||
|
|
||||||
adapter.bootstrap(element, ['ng1Module']).ready(ref => {
|
adapter.bootstrap(element, ['ng1Module']).ready(ref => {
|
||||||
const ng1 = element.querySelector('ng1') !;
|
const ng1 = element.querySelector('ng1')!;
|
||||||
const ng1Controller = angular.element(ng1).controller !('ng1');
|
const ng1Controller = angular.element(ng1).controller!('ng1');
|
||||||
|
|
||||||
expect(multiTrim(element.textContent)).toBe('Inside: - | Outside: foo, bar');
|
expect(multiTrim(element.textContent)).toBe('Inside: - | Outside: foo, bar');
|
||||||
|
|
||||||
|
@ -1204,7 +1235,9 @@ withEachNg1Version(() => {
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
template: '{{someText}} - Length: {{data.length}}',
|
template: '{{someText}} - Length: {{data.length}}',
|
||||||
scope: {data: '='},
|
scope: {data: '='},
|
||||||
controller: function($scope: any) { $scope.someText = 'ng1 - Data: ' + $scope.data; }
|
controller: function($scope: any) {
|
||||||
|
$scope.someText = 'ng1 - Data: ' + $scope.data;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1248,7 +1281,9 @@ withEachNg1Version(() => {
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
template: '{{someText}} - Length: {{data.length}}',
|
template: '{{someText}} - Length: {{data.length}}',
|
||||||
scope: {data: '='},
|
scope: {data: '='},
|
||||||
link: function($scope: any) { $scope.someText = 'ng1 - Data: ' + $scope.data; }
|
link: function($scope: any) {
|
||||||
|
$scope.someText = 'ng1 - Data: ' + $scope.data;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1291,7 +1326,9 @@ withEachNg1Version(() => {
|
||||||
cbFn(200, `${method}:${url}`);
|
cbFn(200, `${method}:${url}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
const ng1 = () => { return {templateUrl: 'url.html'}; };
|
const ng1 = () => {
|
||||||
|
return {templateUrl: 'url.html'};
|
||||||
|
};
|
||||||
ng1Module.directive('ng1', ng1);
|
ng1Module.directive('ng1', ng1);
|
||||||
@Component({selector: 'ng2', template: '<ng1></ng1>'})
|
@Component({selector: 'ng2', template: '<ng1></ng1>'})
|
||||||
class Ng2 {
|
class Ng2 {
|
||||||
|
@ -1320,7 +1357,13 @@ withEachNg1Version(() => {
|
||||||
cbFn(200, `${method}:${url}`);
|
cbFn(200, `${method}:${url}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
const ng1 = () => { return {templateUrl() { return 'url.html'; }}; };
|
const ng1 = () => {
|
||||||
|
return {
|
||||||
|
templateUrl() {
|
||||||
|
return 'url.html';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
ng1Module.directive('ng1', ng1);
|
ng1Module.directive('ng1', ng1);
|
||||||
@Component({selector: 'ng2', template: '<ng1></ng1>'})
|
@Component({selector: 'ng2', template: '<ng1></ng1>'})
|
||||||
class Ng2 {
|
class Ng2 {
|
||||||
|
@ -1345,7 +1388,9 @@ withEachNg1Version(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const ng1Module = angular.module_('ng1', []);
|
const ng1Module = angular.module_('ng1', []);
|
||||||
|
|
||||||
const ng1 = () => { return {template: ''}; };
|
const ng1 = () => {
|
||||||
|
return {template: ''};
|
||||||
|
};
|
||||||
ng1Module.directive('ng1', ng1);
|
ng1Module.directive('ng1', ng1);
|
||||||
|
|
||||||
@Component({selector: 'ng2', template: '<ng1></ng1>'})
|
@Component({selector: 'ng2', template: '<ng1></ng1>'})
|
||||||
|
@ -1371,7 +1416,13 @@ withEachNg1Version(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const ng1Module = angular.module_('ng1', []);
|
const ng1Module = angular.module_('ng1', []);
|
||||||
|
|
||||||
const ng1 = () => { return {template() { return ''; }}; };
|
const ng1 = () => {
|
||||||
|
return {
|
||||||
|
template() {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
ng1Module.directive('ng1', ng1);
|
ng1Module.directive('ng1', ng1);
|
||||||
|
|
||||||
@Component({selector: 'ng2', template: '<ng1></ng1>'})
|
@Component({selector: 'ng2', template: '<ng1></ng1>'})
|
||||||
|
@ -1398,7 +1449,9 @@ withEachNg1Version(() => {
|
||||||
const ng1Module = angular.module_('ng1', []);
|
const ng1Module = angular.module_('ng1', []);
|
||||||
ng1Module.run(($templateCache: any) => $templateCache.put('url.html', 'WORKS'));
|
ng1Module.run(($templateCache: any) => $templateCache.put('url.html', 'WORKS'));
|
||||||
|
|
||||||
const ng1 = () => { return {templateUrl: 'url.html'}; };
|
const ng1 = () => {
|
||||||
|
return {templateUrl: 'url.html'};
|
||||||
|
};
|
||||||
ng1Module.directive('ng1', ng1);
|
ng1Module.directive('ng1', ng1);
|
||||||
|
|
||||||
@Component({selector: 'ng2', template: '<ng1></ng1>'})
|
@Component({selector: 'ng2', template: '<ng1></ng1>'})
|
||||||
|
@ -1431,13 +1484,20 @@ withEachNg1Version(() => {
|
||||||
'{{ctl.scope}}; {{ctl.isClass}}; {{ctl.hasElement}}; {{ctl.isPublished()}}',
|
'{{ctl.scope}}; {{ctl.isClass}}; {{ctl.hasElement}}; {{ctl.isPublished()}}',
|
||||||
controllerAs: 'ctl',
|
controllerAs: 'ctl',
|
||||||
controller: class {
|
controller: class {
|
||||||
scope: any; hasElement: string; $element: any; isClass: any;
|
scope: any;
|
||||||
|
hasElement: string;
|
||||||
|
$element: any;
|
||||||
|
isClass: any;
|
||||||
constructor($scope: any, $element: any) {
|
constructor($scope: any, $element: any) {
|
||||||
this.verifyIAmAClass();
|
this.verifyIAmAClass();
|
||||||
this.scope = $scope.$parent.$parent == $scope.$root ? 'scope' : 'wrong-scope';
|
this.scope = $scope.$parent.$parent == $scope.$root ? 'scope' : 'wrong-scope';
|
||||||
this.hasElement = $element[0].nodeName;
|
this.hasElement = $element[0].nodeName;
|
||||||
this.$element = $element;
|
this.$element = $element;
|
||||||
} verifyIAmAClass() { this.isClass = 'isClass'; } isPublished() {
|
}
|
||||||
|
verifyIAmAClass() {
|
||||||
|
this.isClass = 'isClass';
|
||||||
|
}
|
||||||
|
isPublished() {
|
||||||
return this.$element.controller('ng1') == this ? 'published' : 'not-published';
|
return this.$element.controller('ng1') == this ? 'published' : 'not-published';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1543,7 +1603,9 @@ withEachNg1Version(() => {
|
||||||
template: '{{ctl.status}}',
|
template: '{{ctl.status}}',
|
||||||
require: 'ng1',
|
require: 'ng1',
|
||||||
controllerAs: 'ctrl',
|
controllerAs: 'ctrl',
|
||||||
controller: class {status = 'WORKS';},
|
controller: class {
|
||||||
|
status = 'WORKS';
|
||||||
|
},
|
||||||
link: function(scope: any, element: any, attrs: any, linkController: any) {
|
link: function(scope: any, element: any, attrs: any, linkController: any) {
|
||||||
expect(scope.$root).toEqual($rootScope);
|
expect(scope.$root).toEqual($rootScope);
|
||||||
expect(element[0].nodeName).toEqual('NG1');
|
expect(element[0].nodeName).toEqual('NG1');
|
||||||
|
@ -1577,7 +1639,13 @@ withEachNg1Version(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const ng1Module = angular.module_('ng1', []);
|
const ng1Module = angular.module_('ng1', []);
|
||||||
|
|
||||||
const parent = () => { return {controller: class {parent = 'PARENT';}}; };
|
const parent = () => {
|
||||||
|
return {
|
||||||
|
controller: class {
|
||||||
|
parent = 'PARENT';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
const ng1 = () => {
|
const ng1 = () => {
|
||||||
return {
|
return {
|
||||||
scope: {title: '@'},
|
scope: {title: '@'},
|
||||||
|
@ -1585,7 +1653,9 @@ withEachNg1Version(() => {
|
||||||
template: '{{parent.parent}}:{{ng1.status}}',
|
template: '{{parent.parent}}:{{ng1.status}}',
|
||||||
require: ['ng1', '^parent', '?^^notFound'],
|
require: ['ng1', '^parent', '?^^notFound'],
|
||||||
controllerAs: 'ctrl',
|
controllerAs: 'ctrl',
|
||||||
controller: class {status = 'WORKS';},
|
controller: class {
|
||||||
|
status = 'WORKS';
|
||||||
|
},
|
||||||
link: function(scope: any, element: any, attrs: any, linkControllers: any) {
|
link: function(scope: any, element: any, attrs: any, linkControllers: any) {
|
||||||
expect(linkControllers[0].status).toEqual('WORKS');
|
expect(linkControllers[0].status).toEqual('WORKS');
|
||||||
expect(linkControllers[1].parent).toEqual('PARENT');
|
expect(linkControllers[1].parent).toEqual('PARENT');
|
||||||
|
@ -1633,16 +1703,21 @@ withEachNg1Version(() => {
|
||||||
scope: {},
|
scope: {},
|
||||||
bindToController: true,
|
bindToController: true,
|
||||||
controllerAs: '$ctrl',
|
controllerAs: '$ctrl',
|
||||||
controller: class {$onInit() { $onInitSpyA(); }}
|
controller: class {
|
||||||
|
$onInit() {
|
||||||
|
$onInitSpyA();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
.directive('ng1B', () => ({
|
||||||
|
template: '',
|
||||||
|
scope: {},
|
||||||
|
bindToController: false,
|
||||||
|
controllerAs: '$ctrl',
|
||||||
|
controller: function(this: any) {
|
||||||
|
this.$onInit = $onInitSpyB;
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
.directive(
|
|
||||||
'ng1B', () => ({
|
|
||||||
template: '',
|
|
||||||
scope: {},
|
|
||||||
bindToController: false,
|
|
||||||
controllerAs: '$ctrl',
|
|
||||||
controller: function(this: any) { this.$onInit = $onInitSpyB; }
|
|
||||||
}))
|
|
||||||
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
|
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
@ -1718,7 +1793,9 @@ withEachNg1Version(() => {
|
||||||
|
|
||||||
@Component({selector: 'ng2', template: '<ng1-a></ng1-a> | <ng1-b></ng1-b>'})
|
@Component({selector: 'ng2', template: '<ng1-a></ng1-a> | <ng1-b></ng1-b>'})
|
||||||
class Ng2Component {
|
class Ng2Component {
|
||||||
constructor(cd: ChangeDetectorRef) { changeDetector = cd; }
|
constructor(cd: ChangeDetectorRef) {
|
||||||
|
changeDetector = cd;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
angular.module_('ng1', [])
|
angular.module_('ng1', [])
|
||||||
|
@ -1727,16 +1804,21 @@ withEachNg1Version(() => {
|
||||||
scope: {},
|
scope: {},
|
||||||
bindToController: true,
|
bindToController: true,
|
||||||
controllerAs: '$ctrl',
|
controllerAs: '$ctrl',
|
||||||
controller: class {$doCheck() { $doCheckSpyA(); }}
|
controller: class {
|
||||||
|
$doCheck() {
|
||||||
|
$doCheckSpyA();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
.directive('ng1B', () => ({
|
||||||
|
template: '',
|
||||||
|
scope: {},
|
||||||
|
bindToController: false,
|
||||||
|
controllerAs: '$ctrl',
|
||||||
|
controller: function(this: any) {
|
||||||
|
this.$doCheck = $doCheckSpyB;
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
.directive(
|
|
||||||
'ng1B', () => ({
|
|
||||||
template: '',
|
|
||||||
scope: {},
|
|
||||||
bindToController: false,
|
|
||||||
controllerAs: '$ctrl',
|
|
||||||
controller: function(this: any) { this.$doCheck = $doCheckSpyB; }
|
|
||||||
}))
|
|
||||||
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
|
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
@ -1773,7 +1855,9 @@ withEachNg1Version(() => {
|
||||||
|
|
||||||
@Component({selector: 'ng2', template: '<ng1-a></ng1-a> | <ng1-b></ng1-b>'})
|
@Component({selector: 'ng2', template: '<ng1-a></ng1-a> | <ng1-b></ng1-b>'})
|
||||||
class Ng2Component {
|
class Ng2Component {
|
||||||
constructor(cd: ChangeDetectorRef) { changeDetector = cd; }
|
constructor(cd: ChangeDetectorRef) {
|
||||||
|
changeDetector = cd;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
angular.module_('ng1', [])
|
angular.module_('ng1', [])
|
||||||
|
@ -1835,16 +1919,21 @@ withEachNg1Version(() => {
|
||||||
scope: {},
|
scope: {},
|
||||||
bindToController: true,
|
bindToController: true,
|
||||||
controllerAs: '$ctrl',
|
controllerAs: '$ctrl',
|
||||||
controller: class {$postLink() { $postLinkSpyA(); }}
|
controller: class {
|
||||||
|
$postLink() {
|
||||||
|
$postLinkSpyA();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
.directive('ng1B', () => ({
|
||||||
|
template: '',
|
||||||
|
scope: {},
|
||||||
|
bindToController: false,
|
||||||
|
controllerAs: '$ctrl',
|
||||||
|
controller: function(this: any) {
|
||||||
|
this.$postLink = $postLinkSpyB;
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
.directive(
|
|
||||||
'ng1B', () => ({
|
|
||||||
template: '',
|
|
||||||
scope: {},
|
|
||||||
bindToController: false,
|
|
||||||
controllerAs: '$ctrl',
|
|
||||||
controller: function(this: any) { this.$postLink = $postLinkSpyB; }
|
|
||||||
}))
|
|
||||||
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
|
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
@ -1924,7 +2013,9 @@ withEachNg1Version(() => {
|
||||||
template: '<ng1-a [valA]="val"></ng1-a> | <ng1-b [valB]="val"></ng1-b>'
|
template: '<ng1-a [valA]="val"></ng1-a> | <ng1-b [valB]="val"></ng1-b>'
|
||||||
})
|
})
|
||||||
class Ng2Component {
|
class Ng2Component {
|
||||||
constructor() { ng2Instance = this; }
|
constructor() {
|
||||||
|
ng2Instance = this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
angular.module_('ng1', [])
|
angular.module_('ng1', [])
|
||||||
|
@ -1937,17 +2028,17 @@ withEachNg1Version(() => {
|
||||||
this.$onChanges = $onChangesControllerSpyA;
|
this.$onChanges = $onChangesControllerSpyA;
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
.directive(
|
.directive('ng1B', () => ({
|
||||||
'ng1B',
|
template: '',
|
||||||
() => ({
|
scope: {valB: '<'},
|
||||||
template: '',
|
bindToController: false,
|
||||||
scope: {valB: '<'},
|
controllerAs: '$ctrl',
|
||||||
bindToController: false,
|
controller: class {
|
||||||
controllerAs: '$ctrl',
|
$onChanges(changes: SimpleChanges) {
|
||||||
controller: class {
|
$onChangesControllerSpyB(changes);
|
||||||
$onChanges(changes: SimpleChanges) { $onChangesControllerSpyB(changes); }
|
}
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
.directive('ng2', adapter.downgradeNg2Component(Ng2Component))
|
.directive('ng2', adapter.downgradeNg2Component(Ng2Component))
|
||||||
.run(($rootScope: angular.IRootScopeService) => {
|
.run(($rootScope: angular.IRootScopeService) => {
|
||||||
Object.getPrototypeOf($rootScope).$onChanges = $onChangesScopeSpy;
|
Object.getPrototypeOf($rootScope).$onChanges = $onChangesScopeSpy;
|
||||||
|
@ -2022,7 +2113,9 @@ withEachNg1Version(() => {
|
||||||
})
|
})
|
||||||
class Ng2Component {
|
class Ng2Component {
|
||||||
ng2Destroy: boolean = false;
|
ng2Destroy: boolean = false;
|
||||||
constructor() { ng2ComponentInstance = this; }
|
constructor() {
|
||||||
|
ng2ComponentInstance = this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// On browsers that don't support `requestAnimationFrame` (IE 9, Android <= 4.3),
|
// On browsers that don't support `requestAnimationFrame` (IE 9, Android <= 4.3),
|
||||||
|
@ -2036,16 +2129,21 @@ withEachNg1Version(() => {
|
||||||
scope: {},
|
scope: {},
|
||||||
bindToController: true,
|
bindToController: true,
|
||||||
controllerAs: '$ctrl',
|
controllerAs: '$ctrl',
|
||||||
controller: class {$onDestroy() { $onDestroySpyA(); }}
|
controller: class {
|
||||||
|
$onDestroy() {
|
||||||
|
$onDestroySpyA();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
.directive('ng1B', () => ({
|
||||||
|
template: '',
|
||||||
|
scope: {},
|
||||||
|
bindToController: false,
|
||||||
|
controllerAs: '$ctrl',
|
||||||
|
controller: function(this: any) {
|
||||||
|
this.$onDestroy = $onDestroySpyB;
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
.directive(
|
|
||||||
'ng1B', () => ({
|
|
||||||
template: '',
|
|
||||||
scope: {},
|
|
||||||
bindToController: false,
|
|
||||||
controllerAs: '$ctrl',
|
|
||||||
controller: function(this: any) { this.$onDestroy = $onDestroySpyB; }
|
|
||||||
}))
|
|
||||||
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
|
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
@ -2112,7 +2210,9 @@ withEachNg1Version(() => {
|
||||||
})
|
})
|
||||||
class Ng2Component {
|
class Ng2Component {
|
||||||
ng2Destroy: boolean = false;
|
ng2Destroy: boolean = false;
|
||||||
constructor() { ng2ComponentInstance = this; }
|
constructor() {
|
||||||
|
ng2ComponentInstance = this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// On browsers that don't support `requestAnimationFrame` (IE 9, Android <= 4.3),
|
// On browsers that don't support `requestAnimationFrame` (IE 9, Android <= 4.3),
|
||||||
|
@ -2187,7 +2287,9 @@ withEachNg1Version(() => {
|
||||||
@Component({selector: 'ng2', template: '<div *ngIf="!ng2Destroy"><ng1></ng1></div>'})
|
@Component({selector: 'ng2', template: '<div *ngIf="!ng2Destroy"><ng1></ng1></div>'})
|
||||||
class Ng2Component {
|
class Ng2Component {
|
||||||
ng2Destroy: boolean = false;
|
ng2Destroy: boolean = false;
|
||||||
constructor() { ng2ComponentInstance = this; }
|
constructor() {
|
||||||
|
ng2ComponentInstance = this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// On browsers that don't support `requestAnimationFrame` (IE 9, Android <= 4.3),
|
// On browsers that don't support `requestAnimationFrame` (IE 9, Android <= 4.3),
|
||||||
|
@ -2233,7 +2335,9 @@ withEachNg1Version(() => {
|
||||||
@Component({selector: 'ng2', template: '<div *ngIf="!ng2Destroy"><ng1></ng1></div>'})
|
@Component({selector: 'ng2', template: '<div *ngIf="!ng2Destroy"><ng1></ng1></div>'})
|
||||||
class Ng2Component {
|
class Ng2Component {
|
||||||
ng2Destroy: boolean = false;
|
ng2Destroy: boolean = false;
|
||||||
constructor() { ng2ComponentInstance = this; }
|
constructor() {
|
||||||
|
ng2ComponentInstance = this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// On browsers that don't support `requestAnimationFrame` (IE 9, Android <= 4.3),
|
// On browsers that don't support `requestAnimationFrame` (IE 9, Android <= 4.3),
|
||||||
|
@ -2245,8 +2349,8 @@ withEachNg1Version(() => {
|
||||||
.component('ng1', {
|
.component('ng1', {
|
||||||
controller: class {
|
controller: class {
|
||||||
constructor(private $element: angular.IAugmentedJQuery) {} $onInit() {
|
constructor(private $element: angular.IAugmentedJQuery) {} $onInit() {
|
||||||
this.$element.on !('$destroy', elementDestroyListener);
|
this.$element.on!('$destroy', elementDestroyListener);
|
||||||
this.$element.contents !().on !('$destroy', descendantDestroyListener);
|
this.$element.contents!().on!('$destroy', descendantDestroyListener);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
template: '<div></div>'
|
template: '<div></div>'
|
||||||
|
@ -2287,8 +2391,8 @@ withEachNg1Version(() => {
|
||||||
const ng1Component: angular.IComponent = {
|
const ng1Component: angular.IComponent = {
|
||||||
controller: class {
|
controller: class {
|
||||||
constructor(private $element: angular.IAugmentedJQuery) {} $onInit() {
|
constructor(private $element: angular.IAugmentedJQuery) {} $onInit() {
|
||||||
this.$element.data !('test', 1);
|
this.$element.data!('test', 1);
|
||||||
this.$element.contents !().data !('test', 2);
|
this.$element.contents!().data!('test', 2);
|
||||||
|
|
||||||
ng1ComponentElement = this.$element;
|
ng1ComponentElement = this.$element;
|
||||||
}
|
}
|
||||||
|
@ -2301,7 +2405,9 @@ withEachNg1Version(() => {
|
||||||
class Ng2ComponentA {
|
class Ng2ComponentA {
|
||||||
destroyIt = false;
|
destroyIt = false;
|
||||||
|
|
||||||
constructor() { ng2ComponentAInstance = this; }
|
constructor() {
|
||||||
|
ng2ComponentAInstance = this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component({selector: 'ng2B', template: '<ng1></ng1>'})
|
@Component({selector: 'ng2B', template: '<ng1></ng1>'})
|
||||||
|
@ -2330,15 +2436,15 @@ withEachNg1Version(() => {
|
||||||
const $rootScope = ref.ng1RootScope as any;
|
const $rootScope = ref.ng1RootScope as any;
|
||||||
tick();
|
tick();
|
||||||
$rootScope.$digest();
|
$rootScope.$digest();
|
||||||
expect(ng1ComponentElement.data !('test')).toBe(1);
|
expect(ng1ComponentElement.data!('test')).toBe(1);
|
||||||
expect(ng1ComponentElement.contents !().data !('test')).toBe(2);
|
expect(ng1ComponentElement.contents!().data!('test')).toBe(2);
|
||||||
|
|
||||||
ng2ComponentAInstance.destroyIt = true;
|
ng2ComponentAInstance.destroyIt = true;
|
||||||
tick();
|
tick();
|
||||||
$rootScope.$digest();
|
$rootScope.$digest();
|
||||||
|
|
||||||
expect(ng1ComponentElement.data !('test')).toBeUndefined();
|
expect(ng1ComponentElement.data!('test')).toBeUndefined();
|
||||||
expect(ng1ComponentElement.contents !().data !('test')).toBeUndefined();
|
expect(ng1ComponentElement.contents!().data!('test')).toBeUndefined();
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -2353,10 +2459,10 @@ withEachNg1Version(() => {
|
||||||
const ng1Component: angular.IComponent = {
|
const ng1Component: angular.IComponent = {
|
||||||
controller: class {
|
controller: class {
|
||||||
constructor(private $element: angular.IAugmentedJQuery) {} $onInit() {
|
constructor(private $element: angular.IAugmentedJQuery) {} $onInit() {
|
||||||
ng1DescendantElement = this.$element.contents !();
|
ng1DescendantElement = this.$element.contents!();
|
||||||
|
|
||||||
this.$element.on !('click', elementClickListener);
|
this.$element.on!('click', elementClickListener);
|
||||||
ng1DescendantElement.on !('click', descendantClickListener);
|
ng1DescendantElement.on!('click', descendantClickListener);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
template: '<div></div>'
|
template: '<div></div>'
|
||||||
|
@ -2367,7 +2473,9 @@ withEachNg1Version(() => {
|
||||||
class Ng2ComponentA {
|
class Ng2ComponentA {
|
||||||
destroyIt = false;
|
destroyIt = false;
|
||||||
|
|
||||||
constructor() { ng2ComponentAInstance = this; }
|
constructor() {
|
||||||
|
ng2ComponentAInstance = this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component({selector: 'ng2B', template: '<ng1></ng1>'})
|
@Component({selector: 'ng2B', template: '<ng1></ng1>'})
|
||||||
|
@ -2420,7 +2528,11 @@ withEachNg1Version(() => {
|
||||||
const ng1Directive: angular.IDirective = {
|
const ng1Directive: angular.IDirective = {
|
||||||
template: '',
|
template: '',
|
||||||
link: {pre: () => log.push('ng1-pre')},
|
link: {pre: () => log.push('ng1-pre')},
|
||||||
controller: class {constructor() { log.push('ng1-ctrl'); }}
|
controller: class {
|
||||||
|
constructor() {
|
||||||
|
log.push('ng1-ctrl');
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Define `Ng2Component`
|
// Define `Ng2Component`
|
||||||
|
@ -2577,7 +2689,11 @@ withEachNg1Version(() => {
|
||||||
const ng1Directive: angular.IDirective = {
|
const ng1Directive: angular.IDirective = {
|
||||||
template: '',
|
template: '',
|
||||||
link: () => log.push('ng1-post'),
|
link: () => log.push('ng1-post'),
|
||||||
controller: class {$postLink() { log.push('ng1-$post'); }}
|
controller: class {
|
||||||
|
$postLink() {
|
||||||
|
log.push('ng1-$post');
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Define `Ng2Component`
|
// Define `Ng2Component`
|
||||||
|
@ -2627,13 +2743,17 @@ withEachNg1Version(() => {
|
||||||
class Ng2ComponentA {
|
class Ng2ComponentA {
|
||||||
value = 'foo';
|
value = 'foo';
|
||||||
showB = false;
|
showB = false;
|
||||||
constructor() { ng2ComponentAInstance = this; }
|
constructor() {
|
||||||
|
ng2ComponentAInstance = this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component({selector: 'ng2B', template: 'ng2B({{ value }})'})
|
@Component({selector: 'ng2B', template: 'ng2B({{ value }})'})
|
||||||
class Ng2ComponentB {
|
class Ng2ComponentB {
|
||||||
value = 'bar';
|
value = 'bar';
|
||||||
constructor() { ng2ComponentBInstance = this; }
|
constructor() {
|
||||||
|
ng2ComponentBInstance = this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define `ng1Module`
|
// Define `ng1Module`
|
||||||
|
@ -2678,7 +2798,10 @@ withEachNg1Version(() => {
|
||||||
template: 'ng1(<div ng-transclude>{{ $ctrl.value }}</div>)',
|
template: 'ng1(<div ng-transclude>{{ $ctrl.value }}</div>)',
|
||||||
transclude: true,
|
transclude: true,
|
||||||
controller: class {
|
controller: class {
|
||||||
value = 'from-ng1'; constructor() { ng1ControllerInstances.push(this); }
|
value = 'from-ng1';
|
||||||
|
constructor() {
|
||||||
|
ng1ControllerInstances.push(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2697,7 +2820,9 @@ withEachNg1Version(() => {
|
||||||
})
|
})
|
||||||
class Ng2Component {
|
class Ng2Component {
|
||||||
value = 'from-ng2';
|
value = 'from-ng2';
|
||||||
constructor() { ng2ComponentInstance = this; }
|
constructor() {
|
||||||
|
ng2ComponentInstance = this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define `ng1Module`
|
// Define `ng1Module`
|
||||||
|
@ -2756,7 +2881,9 @@ withEachNg1Version(() => {
|
||||||
class Ng2Component {
|
class Ng2Component {
|
||||||
x = 'foo';
|
x = 'foo';
|
||||||
y = 'bar';
|
y = 'bar';
|
||||||
constructor() { ng2ComponentInstance = this; }
|
constructor() {
|
||||||
|
ng2ComponentInstance = this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define `ng1Module`
|
// Define `ng1Module`
|
||||||
|
@ -2798,8 +2925,12 @@ withEachNg1Version(() => {
|
||||||
const ng1Component: angular.IComponent = {
|
const ng1Component: angular.IComponent = {
|
||||||
template: 'ng1(default(<div ng-transclude="">fallback-{{ $ctrl.value }}</div>))',
|
template: 'ng1(default(<div ng-transclude="">fallback-{{ $ctrl.value }}</div>))',
|
||||||
transclude: {slotX: 'contentX', slotY: 'contentY'},
|
transclude: {slotX: 'contentX', slotY: 'contentY'},
|
||||||
controller:
|
controller: class {
|
||||||
class {value = 'ng1'; constructor() { ng1ControllerInstances.push(this); }}
|
value = 'ng1';
|
||||||
|
constructor() {
|
||||||
|
ng1ControllerInstances.push(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Define `Ng2Component`
|
// Define `Ng2Component`
|
||||||
|
@ -2830,7 +2961,9 @@ withEachNg1Version(() => {
|
||||||
class Ng2Component {
|
class Ng2Component {
|
||||||
x = 'foo';
|
x = 'foo';
|
||||||
y = 'bar';
|
y = 'bar';
|
||||||
constructor() { ng2ComponentInstance = this; }
|
constructor() {
|
||||||
|
ng2ComponentInstance = this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define `ng1Module`
|
// Define `ng1Module`
|
||||||
|
@ -2880,7 +3013,11 @@ withEachNg1Version(() => {
|
||||||
)`,
|
)`,
|
||||||
transclude: {slotX: '?contentX', slotY: '?contentY'},
|
transclude: {slotX: '?contentX', slotY: '?contentY'},
|
||||||
controller: class {
|
controller: class {
|
||||||
x = 'ng1X'; y = 'ng1Y'; constructor() { ng1ControllerInstances.push(this); }
|
x = 'ng1X';
|
||||||
|
y = 'ng1Y';
|
||||||
|
constructor() {
|
||||||
|
ng1ControllerInstances.push(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2896,7 +3033,9 @@ withEachNg1Version(() => {
|
||||||
class Ng2Component {
|
class Ng2Component {
|
||||||
x = 'ng2X';
|
x = 'ng2X';
|
||||||
y = 'ng2Y';
|
y = 'ng2Y';
|
||||||
constructor() { ng2ComponentInstance = this; }
|
constructor() {
|
||||||
|
ng2ComponentInstance = this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define `ng1Module`
|
// Define `ng1Module`
|
||||||
|
@ -3000,7 +3139,9 @@ withEachNg1Version(() => {
|
||||||
x = 'foo';
|
x = 'foo';
|
||||||
y = 'bar';
|
y = 'bar';
|
||||||
show = true;
|
show = true;
|
||||||
constructor() { ng2ComponentInstance = this; }
|
constructor() {
|
||||||
|
ng2ComponentInstance = this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define `ng1Module`
|
// Define `ng1Module`
|
||||||
|
@ -3202,13 +3343,18 @@ withEachNg1Version(() => {
|
||||||
const ng1Module = angular.module_('ng1', []);
|
const ng1Module = angular.module_('ng1', []);
|
||||||
let a1Injector: angular.IInjectorService|undefined;
|
let a1Injector: angular.IInjectorService|undefined;
|
||||||
ng1Module.run([
|
ng1Module.run([
|
||||||
'$injector', function($injector: angular.IInjectorService) { a1Injector = $injector; }
|
'$injector',
|
||||||
|
function($injector: angular.IInjectorService) {
|
||||||
|
a1Injector = $injector;
|
||||||
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const element = html('<div></div>');
|
const element = html('<div></div>');
|
||||||
window.name = 'NG_DEFER_BOOTSTRAP!' + window.name;
|
window.name = 'NG_DEFER_BOOTSTRAP!' + window.name;
|
||||||
|
|
||||||
adapter.bootstrap(element, [ng1Module.name]).ready((ref) => { ref.dispose(); });
|
adapter.bootstrap(element, [ng1Module.name]).ready((ref) => {
|
||||||
|
ref.dispose();
|
||||||
|
});
|
||||||
|
|
||||||
tick(100);
|
tick(100);
|
||||||
|
|
||||||
|
@ -3275,7 +3421,7 @@ withEachNg1Version(() => {
|
||||||
|
|
||||||
document.body.innerHTML = '<ng2 name="World">project</ng2>';
|
document.body.innerHTML = '<ng2 name="World">project</ng2>';
|
||||||
|
|
||||||
adapter.bootstrap(document.body.firstElementChild !, ['myExample']).ready((ref) => {
|
adapter.bootstrap(document.body.firstElementChild!, ['myExample']).ready((ref) => {
|
||||||
expect(multiTrim(document.body.textContent))
|
expect(multiTrim(document.body.textContent))
|
||||||
.toEqual('ng2[ng1[Hello World!](transclude)](project)');
|
.toEqual('ng2[ng1[Hello World!](transclude)](project)');
|
||||||
ref.dispose();
|
ref.dispose();
|
||||||
|
|
|
@ -284,11 +284,7 @@ describe('bluebird promise', () => {
|
||||||
.each(
|
.each(
|
||||||
BluebirdPromise.map(arr, (item: number) => BluebirdPromise.resolve(item)),
|
BluebirdPromise.map(arr, (item: number) => BluebirdPromise.resolve(item)),
|
||||||
(r: number, idx: number) => {
|
(r: number, idx: number) => {
|
||||||
<<<<<<< HEAD
|
|
||||||
expect(r).toBe(arr[idx]);
|
expect(r).toBe(arr[idx]);
|
||||||
=======
|
|
||||||
expect(r === arr[idx]).toBeTrue();
|
|
||||||
>>>>>>> 253023848d... build: update jasmine to 3.5
|
|
||||||
expect(Zone.current.name).toEqual('bluebird');
|
expect(Zone.current.name).toEqual('bluebird');
|
||||||
})
|
})
|
||||||
.then((r: any) => {
|
.then((r: any) => {
|
||||||
|
@ -309,11 +305,7 @@ describe('bluebird promise', () => {
|
||||||
.mapSeries(
|
.mapSeries(
|
||||||
BluebirdPromise.map(arr, (item: number) => BluebirdPromise.resolve(item)),
|
BluebirdPromise.map(arr, (item: number) => BluebirdPromise.resolve(item)),
|
||||||
(r: number, idx: number) => {
|
(r: number, idx: number) => {
|
||||||
<<<<<<< HEAD
|
|
||||||
expect(r).toBe(arr[idx]);
|
expect(r).toBe(arr[idx]);
|
||||||
=======
|
|
||||||
expect(r === arr[idx]).toBeTrue();
|
|
||||||
>>>>>>> 253023848d... build: update jasmine to 3.5
|
|
||||||
expect(Zone.current.name).toEqual('bluebird');
|
expect(Zone.current.name).toEqual('bluebird');
|
||||||
})
|
})
|
||||||
.then((r: any) => {
|
.then((r: any) => {
|
||||||
|
|
|
@ -21,7 +21,9 @@ describe('crypto test', () => {
|
||||||
const zoneASpec = {
|
const zoneASpec = {
|
||||||
name: 'A',
|
name: 'A',
|
||||||
onScheduleTask: (delegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task):
|
onScheduleTask: (delegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task):
|
||||||
Task => { return delegate.scheduleTask(targetZone, task); }
|
Task => {
|
||||||
|
return delegate.scheduleTask(targetZone, task);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
const zoneA = Zone.current.fork(zoneASpec);
|
const zoneA = Zone.current.fork(zoneASpec);
|
||||||
spyOn(zoneASpec, 'onScheduleTask').and.callThrough();
|
spyOn(zoneASpec, 'onScheduleTask').and.callThrough();
|
||||||
|
@ -44,7 +46,9 @@ describe('crypto test', () => {
|
||||||
const zoneASpec = {
|
const zoneASpec = {
|
||||||
name: 'A',
|
name: 'A',
|
||||||
onScheduleTask: (delegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task):
|
onScheduleTask: (delegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task):
|
||||||
Task => { return delegate.scheduleTask(targetZone, task); }
|
Task => {
|
||||||
|
return delegate.scheduleTask(targetZone, task);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
const zoneA = Zone.current.fork(zoneASpec);
|
const zoneA = Zone.current.fork(zoneASpec);
|
||||||
spyOn(zoneASpec, 'onScheduleTask').and.callThrough();
|
spyOn(zoneASpec, 'onScheduleTask').and.callThrough();
|
||||||
|
|
Loading…
Reference in New Issue