test: move remaining fixmeIvy to test level (#27354)

Moves all of the remaning `describe`-level fixme instances to the `it` level.

PR Close #27354
This commit is contained in:
Kristiyan Kostadinov 2018-11-29 23:34:28 +01:00 committed by Igor Minar
parent 36e7bf1b7b
commit 23bc8edf24
11 changed files with 1566 additions and 1451 deletions

View File

@ -84,7 +84,7 @@ class NestedAsyncTimeoutComp {
}
{
fixmeIvy('unknown') && describe('ComponentFixture', () => {
describe('ComponentFixture', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
@ -94,7 +94,7 @@ class NestedAsyncTimeoutComp {
});
}));
it('should auto detect changes if autoDetectChanges is called', () => {
fixmeIvy('unknown') && it('should auto detect changes if autoDetectChanges is called', () => {
const componentFixture = TestBed.createComponent(AutoDetectComp);
expect(componentFixture.ngZone).not.toBeNull();
@ -108,6 +108,7 @@ class NestedAsyncTimeoutComp {
expect(componentFixture.nativeElement).toHaveText('11');
});
fixmeIvy('unknown') &&
it('should auto detect changes if ComponentFixtureAutoDetect is provided as true',
withModule({providers: [{provide: ComponentFixtureAutoDetect, useValue: true}]}, () => {
@ -120,6 +121,7 @@ class NestedAsyncTimeoutComp {
expect(componentFixture.nativeElement).toHaveText('11');
}));
fixmeIvy('unknown') &&
it('should signal through whenStable when the fixture is stable (autoDetectChanges)',
async(() => {
const componentFixture = TestBed.createComponent(AsyncComp);
@ -139,6 +141,7 @@ class NestedAsyncTimeoutComp {
});
}));
fixmeIvy('unknown') &&
it('should signal through isStable when the fixture is stable (no autoDetectChanges)',
async(() => {
const componentFixture = TestBed.createComponent(AsyncComp);
@ -159,6 +162,7 @@ class NestedAsyncTimeoutComp {
});
}));
fixmeIvy('unknown') &&
it('should wait for macroTask(setTimeout) while checking for whenStable ' +
'(autoDetectChanges)',
async(() => {
@ -179,6 +183,7 @@ class NestedAsyncTimeoutComp {
});
}));
fixmeIvy('unknown') &&
it('should wait for macroTask(setTimeout) while checking for whenStable ' +
'(no autoDetectChanges)',
async(() => {
@ -201,6 +206,7 @@ class NestedAsyncTimeoutComp {
});
}));
fixmeIvy('unknown') &&
it('should wait for nested macroTasks(setTimeout) while checking for whenStable ' +
'(autoDetectChanges)',
async(() => {
@ -223,6 +229,7 @@ class NestedAsyncTimeoutComp {
});
}));
fixmeIvy('unknown') &&
it('should wait for nested macroTasks(setTimeout) while checking for whenStable ' +
'(no autoDetectChanges)',
async(() => {
@ -245,7 +252,9 @@ class NestedAsyncTimeoutComp {
});
}));
it('should stabilize after async task in change detection (autoDetectChanges)', async(() => {
fixmeIvy('unknown') &&
it('should stabilize after async task in change detection (autoDetectChanges)',
async(() => {
const componentFixture = TestBed.createComponent(AsyncChangeComp);
@ -261,7 +270,9 @@ class NestedAsyncTimeoutComp {
});
}));
it('should stabilize after async task in change detection(no autoDetectChanges)', async(() => {
fixmeIvy('unknown') &&
it('should stabilize after async task in change detection(no autoDetectChanges)',
async(() => {
const componentFixture = TestBed.createComponent(AsyncChangeComp);
componentFixture.detectChanges();
@ -290,7 +301,7 @@ class NestedAsyncTimeoutComp {
{providers: [{provide: ComponentFixtureNoNgZone, useValue: true}]});
});
it('calling autoDetectChanges raises an error', () => {
fixmeIvy('unknown') && it('calling autoDetectChanges raises an error', () => {
const componentFixture = TestBed.createComponent(SimpleComp);
expect(() => {
@ -298,6 +309,7 @@ class NestedAsyncTimeoutComp {
}).toThrowError(/Cannot call autoDetectChanges when ComponentFixtureNoNgZone is set/);
});
fixmeIvy('unknown') &&
it('should instantiate a component with valid DOM', async(() => {
const componentFixture = TestBed.createComponent(SimpleComp);
@ -307,7 +319,7 @@ class NestedAsyncTimeoutComp {
expect(componentFixture.nativeElement).toHaveText('Original Simple');
}));
it('should allow changing members of the component', async(() => {
fixmeIvy('unknown') && it('should allow changing members of the component', async(() => {
const componentFixture = TestBed.createComponent(MyIfComp);

View File

@ -169,7 +169,7 @@ class TestApp {
}
{
fixmeIvy('unknown') && describe('debug element', () => {
describe('debug element', () => {
let fixture: ComponentFixture<any>;
beforeEach(async(() => {
@ -192,13 +192,13 @@ class TestApp {
});
}));
it('should list all child nodes', () => {
fixmeIvy('unknown') && it('should list all child nodes', () => {
fixture = TestBed.createComponent(ParentComp);
fixture.detectChanges();
expect(fixture.debugElement.childNodes.length).toEqual(3);
});
it('should list all component child elements', () => {
fixmeIvy('unknown') && it('should list all component child elements', () => {
fixture = TestBed.createComponent(ParentComp);
fixture.detectChanges();
const childEls = fixture.debugElement.children;
@ -225,7 +225,7 @@ class TestApp {
expect(getDOM().hasClass(childNested[0].nativeElement, 'childnested')).toBe(true);
});
it('should list conditional component child elements', () => {
fixmeIvy('unknown') && it('should list conditional component child elements', () => {
fixture = TestBed.createComponent(ConditionalParentComp);
fixture.detectChanges();
@ -246,7 +246,7 @@ class TestApp {
expect(conditionalContentComp.children.length).toEqual(1);
});
it('should list child elements within viewports', () => {
fixmeIvy('unknown') && it('should list child elements within viewports', () => {
fixture = TestBed.createComponent(UsingFor);
fixture.detectChanges();
@ -259,7 +259,7 @@ class TestApp {
expect(list.children.length).toEqual(3);
});
it('should list element attributes', () => {
fixmeIvy('unknown') && it('should list element attributes', () => {
fixture = TestBed.createComponent(TestApp);
fixture.detectChanges();
const bankElem = fixture.debugElement.children[0];
@ -268,7 +268,7 @@ class TestApp {
expect(bankElem.attributes['account']).toEqual('4747');
});
it('should list element classes', () => {
fixmeIvy('unknown') && it('should list element classes', () => {
fixture = TestBed.createComponent(TestApp);
fixture.detectChanges();
const bankElem = fixture.debugElement.children[0];
@ -277,7 +277,7 @@ class TestApp {
expect(bankElem.classes['open']).toBe(false);
});
it('should list element styles', () => {
fixmeIvy('unknown') && it('should list element styles', () => {
fixture = TestBed.createComponent(TestApp);
fixture.detectChanges();
const bankElem = fixture.debugElement.children[0];
@ -286,7 +286,7 @@ class TestApp {
expect(bankElem.styles['color']).toEqual('red');
});
it('should query child elements by css', () => {
fixmeIvy('unknown') && it('should query child elements by css', () => {
fixture = TestBed.createComponent(ParentComp);
fixture.detectChanges();
@ -296,7 +296,7 @@ class TestApp {
expect(getDOM().hasClass(childTestEls[0].nativeElement, 'child-comp-class')).toBe(true);
});
it('should query child elements by directive', () => {
fixmeIvy('unknown') && it('should query child elements by directive', () => {
fixture = TestBed.createComponent(ParentComp);
fixture.detectChanges();
@ -309,21 +309,21 @@ class TestApp {
expect(getDOM().hasClass(childTestEls[3].nativeElement, 'childnested')).toBe(true);
});
it('should list providerTokens', () => {
fixmeIvy('unknown') && it('should list providerTokens', () => {
fixture = TestBed.createComponent(ParentComp);
fixture.detectChanges();
expect(fixture.debugElement.providerTokens).toContain(Logger);
});
it('should list locals', () => {
fixmeIvy('unknown') && it('should list locals', () => {
fixture = TestBed.createComponent(LocalsComp);
fixture.detectChanges();
expect(fixture.debugElement.children[0].references !['alice']).toBeAnInstanceOf(MyDir);
});
it('should allow injecting from the element injector', () => {
fixmeIvy('unknown') && it('should allow injecting from the element injector', () => {
fixture = TestBed.createComponent(ParentComp);
fixture.detectChanges();
@ -332,7 +332,7 @@ class TestApp {
]);
});
it('should list event listeners', () => {
fixmeIvy('unknown') && it('should list event listeners', () => {
fixture = TestBed.createComponent(EventsComp);
fixture.detectChanges();
@ -341,7 +341,7 @@ class TestApp {
});
it('should trigger event handlers', () => {
fixmeIvy('unknown') && it('should trigger event handlers', () => {
fixture = TestBed.createComponent(EventsComp);
fixture.detectChanges();

View File

@ -13,7 +13,7 @@ import {Log} from '@angular/core/testing/src/testing_internal';
import {fixmeIvy} from '@angular/private/testing';
{
fixmeIvy('unknown') && describe('directive lifecycle integration spec', () => {
describe('directive lifecycle integration spec', () => {
let log: Log;
beforeEach(() => {
@ -31,6 +31,7 @@ import {fixmeIvy} from '@angular/private/testing';
beforeEach(inject([Log], (_log: any) => { log = _log; }));
fixmeIvy('unknown') &&
it('should invoke lifecycle methods ngOnChanges > ngOnInit > ngDoCheck > ngAfterContentChecked',
() => {
const fixture = TestBed.createComponent(MyComp5);

View File

@ -18,32 +18,33 @@ const resolvedPromise = Promise.resolve(null);
const ProxyZoneSpec: {assertPresent: () => void} = (Zone as any)['ProxyZoneSpec'];
{
fixmeIvy('unknown') && describe('fake async', () => {
it('should run synchronous code', () => {
describe('fake async', () => {
fixmeIvy('unknown') && it('should run synchronous code', () => {
let ran = false;
fakeAsync(() => { ran = true; })();
expect(ran).toEqual(true);
});
it('should pass arguments to the wrapped function', () => {
fixmeIvy('unknown') && it('should pass arguments to the wrapped function', () => {
fakeAsync((foo: any /** TODO #9100 */, bar: any /** TODO #9100 */) => {
expect(foo).toEqual('foo');
expect(bar).toEqual('bar');
})('foo', 'bar');
});
it('should work with inject()', fakeAsync(inject([Parser], (parser: any /** TODO #9100 */) => {
fixmeIvy('unknown') && it('should work with inject()',
fakeAsync(inject([Parser], (parser: any /** TODO #9100 */) => {
expect(parser).toBeAnInstanceOf(Parser);
})));
it('should throw on nested calls', () => {
fixmeIvy('unknown') && it('should throw on nested calls', () => {
expect(() => {
fakeAsync(() => { fakeAsync((): any /** TODO #9100 */ => null)(); })();
}).toThrowError('fakeAsync() calls can not be nested');
});
it('should flush microtasks before returning', () => {
fixmeIvy('unknown') && it('should flush microtasks before returning', () => {
let thenRan = false;
fakeAsync(() => { resolvedPromise.then(_ => { thenRan = true; }); })();
@ -52,11 +53,11 @@ const ProxyZoneSpec: {assertPresent: () => void} = (Zone as any)['ProxyZoneSpec'
});
it('should propagate the return value',
fixmeIvy('unknown') && it('should propagate the return value',
() => { expect(fakeAsync(() => 'foo')()).toEqual('foo'); });
describe('Promise', () => {
it('should run asynchronous code', fakeAsync(() => {
fixmeIvy('unknown') && it('should run asynchronous code', fakeAsync(() => {
let thenRan = false;
resolvedPromise.then((_) => { thenRan = true; });
@ -66,7 +67,7 @@ const ProxyZoneSpec: {assertPresent: () => void} = (Zone as any)['ProxyZoneSpec'
expect(thenRan).toEqual(true);
}));
it('should run chained thens', fakeAsync(() => {
fixmeIvy('unknown') && it('should run chained thens', fakeAsync(() => {
const log = new Log();
resolvedPromise.then((_) => log.add(1)).then((_) => log.add(2));
@ -77,7 +78,7 @@ const ProxyZoneSpec: {assertPresent: () => void} = (Zone as any)['ProxyZoneSpec'
expect(log.result()).toEqual('1; 2');
}));
it('should run Promise created in Promise', fakeAsync(() => {
fixmeIvy('unknown') && it('should run Promise created in Promise', fakeAsync(() => {
const log = new Log();
resolvedPromise.then((_) => {
@ -91,6 +92,7 @@ const ProxyZoneSpec: {assertPresent: () => void} = (Zone as any)['ProxyZoneSpec'
expect(log.result()).toEqual('1; 2');
}));
fixmeIvy('unknown') &&
it('should complain if the test throws an exception during async calls', () => {
expect(() => {
fakeAsync(() => {
@ -100,13 +102,14 @@ const ProxyZoneSpec: {assertPresent: () => void} = (Zone as any)['ProxyZoneSpec'
}).toThrowError(/Uncaught \(in promise\): Error: async/);
});
it('should complain if a test throws an exception', () => {
fixmeIvy('unknown') && it('should complain if a test throws an exception', () => {
expect(() => { fakeAsync(() => { throw new Error('sync'); })(); }).toThrowError('sync');
});
});
describe('timers', () => {
fixmeIvy('unknown') &&
it('should run queued zero duration timer on zero tick', fakeAsync(() => {
let ran = false;
setTimeout(() => { ran = true; }, 0);
@ -118,6 +121,7 @@ const ProxyZoneSpec: {assertPresent: () => void} = (Zone as any)['ProxyZoneSpec'
}));
fixmeIvy('unknown') &&
it('should run queued timer after sufficient clock ticks', fakeAsync(() => {
let ran = false;
setTimeout(() => { ran = true; }, 10);
@ -129,7 +133,7 @@ const ProxyZoneSpec: {assertPresent: () => void} = (Zone as any)['ProxyZoneSpec'
expect(ran).toEqual(true);
}));
it('should run queued timer only once', fakeAsync(() => {
fixmeIvy('unknown') && it('should run queued timer only once', fakeAsync(() => {
let cycles = 0;
setTimeout(() => { cycles++; }, 10);
@ -143,7 +147,7 @@ const ProxyZoneSpec: {assertPresent: () => void} = (Zone as any)['ProxyZoneSpec'
expect(cycles).toEqual(1);
}));
it('should not run cancelled timer', fakeAsync(() => {
fixmeIvy('unknown') && it('should not run cancelled timer', fakeAsync(() => {
let ran = false;
const id = setTimeout(() => { ran = true; }, 10);
clearTimeout(id);
@ -152,19 +156,19 @@ const ProxyZoneSpec: {assertPresent: () => void} = (Zone as any)['ProxyZoneSpec'
expect(ran).toEqual(false);
}));
it('should throw an error on dangling timers', () => {
fixmeIvy('unknown') && it('should throw an error on dangling timers', () => {
expect(() => {
fakeAsync(() => { setTimeout(() => {}, 10); })();
}).toThrowError('1 timer(s) still in the queue.');
});
it('should throw an error on dangling periodic timers', () => {
fixmeIvy('unknown') && it('should throw an error on dangling periodic timers', () => {
expect(() => {
fakeAsync(() => { setInterval(() => {}, 10); })();
}).toThrowError('1 periodic timer(s) still in the queue.');
});
it('should run periodic timers', fakeAsync(() => {
fixmeIvy('unknown') && it('should run periodic timers', fakeAsync(() => {
let cycles = 0;
const id = setInterval(() => { cycles++; }, 10);
@ -179,7 +183,7 @@ const ProxyZoneSpec: {assertPresent: () => void} = (Zone as any)['ProxyZoneSpec'
clearInterval(id);
}));
it('should not run cancelled periodic timer', fakeAsync(() => {
fixmeIvy('unknown') && it('should not run cancelled periodic timer', fakeAsync(() => {
let ran = false;
const id = setInterval(() => { ran = true; }, 10);
clearInterval(id);
@ -188,6 +192,7 @@ const ProxyZoneSpec: {assertPresent: () => void} = (Zone as any)['ProxyZoneSpec'
expect(ran).toEqual(false);
}));
fixmeIvy('unknown') &&
it('should be able to cancel periodic timers from a callback', fakeAsync(() => {
let cycles = 0;
let id: any /** TODO #9100 */;
@ -204,7 +209,7 @@ const ProxyZoneSpec: {assertPresent: () => void} = (Zone as any)['ProxyZoneSpec'
expect(cycles).toEqual(1);
}));
it('should clear periodic timers', fakeAsync(() => {
fixmeIvy('unknown') && it('should clear periodic timers', fakeAsync(() => {
let cycles = 0;
const id = setInterval(() => { cycles++; }, 10);
@ -222,7 +227,7 @@ const ProxyZoneSpec: {assertPresent: () => void} = (Zone as any)['ProxyZoneSpec'
expect(cycles).toEqual(2);
}));
it('should process microtasks before timers', fakeAsync(() => {
fixmeIvy('unknown') && it('should process microtasks before timers', fakeAsync(() => {
const log = new Log();
resolvedPromise.then((_) => log.add('microtask'));
@ -238,6 +243,7 @@ const ProxyZoneSpec: {assertPresent: () => void} = (Zone as any)['ProxyZoneSpec'
clearInterval(id);
}));
fixmeIvy('unknown') &&
it('should process micro-tasks created in timers before next timers', fakeAsync(() => {
const log = new Log();
@ -264,7 +270,7 @@ const ProxyZoneSpec: {assertPresent: () => void} = (Zone as any)['ProxyZoneSpec'
clearInterval(id);
}));
it('should flush tasks', fakeAsync(() => {
fixmeIvy('unknown') && it('should flush tasks', fakeAsync(() => {
let ran = false;
setTimeout(() => { ran = true; }, 10);
@ -272,7 +278,7 @@ const ProxyZoneSpec: {assertPresent: () => void} = (Zone as any)['ProxyZoneSpec'
expect(ran).toEqual(true);
}));
it('should flush multiple tasks', fakeAsync(() => {
fixmeIvy('unknown') && it('should flush multiple tasks', fakeAsync(() => {
let ran = false;
let ran2 = false;
setTimeout(() => { ran = true; }, 10);
@ -285,7 +291,7 @@ const ProxyZoneSpec: {assertPresent: () => void} = (Zone as any)['ProxyZoneSpec'
expect(elapsed).toEqual(30);
}));
it('should move periodic tasks', fakeAsync(() => {
fixmeIvy('unknown') && it('should move periodic tasks', fakeAsync(() => {
let ran = false;
let count = 0;
setInterval(() => { count++; }, 10);
@ -302,25 +308,25 @@ const ProxyZoneSpec: {assertPresent: () => void} = (Zone as any)['ProxyZoneSpec'
});
describe('outside of the fakeAsync zone', () => {
it('calling flushMicrotasks should throw', () => {
fixmeIvy('unknown') && it('calling flushMicrotasks should throw', () => {
expect(() => {
flushMicrotasks();
}).toThrowError('The code should be running in the fakeAsync zone to call this function');
});
it('calling tick should throw', () => {
fixmeIvy('unknown') && it('calling tick should throw', () => {
expect(() => {
tick();
}).toThrowError('The code should be running in the fakeAsync zone to call this function');
});
it('calling flush should throw', () => {
fixmeIvy('unknown') && it('calling flush should throw', () => {
expect(() => {
flush();
}).toThrowError('The code should be running in the fakeAsync zone to call this function');
});
it('calling discardPeriodicTasks should throw', () => {
fixmeIvy('unknown') && it('calling discardPeriodicTasks should throw', () => {
expect(() => {
discardPeriodicTasks();
}).toThrowError('The code should be running in the fakeAsync zone to call this function');
@ -332,7 +338,7 @@ const ProxyZoneSpec: {assertPresent: () => void} = (Zone as any)['ProxyZoneSpec'
let zoneInTest1: Zone;
beforeEach(fakeAsync(() => { zoneInBeforeEach = Zone.current; }));
it('should use the same zone as in beforeEach', fakeAsync(() => {
fixmeIvy('unknown') && it('should use the same zone as in beforeEach', fakeAsync(() => {
zoneInTest1 = Zone.current;
expect(zoneInTest1).toBe(zoneInBeforeEach);
}));
@ -344,7 +350,9 @@ const ProxyZoneSpec: {assertPresent: () => void} = (Zone as any)['ProxyZoneSpec'
afterEach(() => { ProxyZoneSpec.assertPresent(); });
it('should allow fakeAsync zone to retroactively set a zoneSpec outside of fakeAsync', () => {
fixmeIvy('unknown') &&
it('should allow fakeAsync zone to retroactively set a zoneSpec outside of fakeAsync',
() => {
ProxyZoneSpec.assertPresent();
let state: string = 'not run';
const testZone = Zone.current.fork({name: 'test-zone'});

View File

@ -13,11 +13,13 @@ import {expect} from '@angular/platform-browser/testing/src/matchers';
import {fixmeIvy} from '@angular/private/testing';
{
fixmeIvy('unknown') && describe('forwardRef integration', function() {
describe('forwardRef integration', function() {
beforeEach(() => { TestBed.configureTestingModule({imports: [Module], declarations: [App]}); });
fixmeIvy('unknown') &&
it('should instantiate components which are declared using forwardRef', () => {
const a = TestBed.configureTestingModule({schemas: [NO_ERRORS_SCHEMA]}).createComponent(App);
const a =
TestBed.configureTestingModule({schemas: [NO_ERRORS_SCHEMA]}).createComponent(App);
a.detectChanges();
expect(asNativeElements(a.debugElement.children)).toHaveText('frame(lock)');
expect(TestBed.get(ModuleFrame)).toBeDefined();

View File

@ -16,7 +16,7 @@ import {fixmeIvy} from '@angular/private/testing';
{
// ivy fix in https://github.com/angular/angular/pull/26871
fixmeIvy('FW-514: ngSummary shims not generated by ngtsc') && describe('Jit Summaries', () => {
describe('Jit Summaries', () => {
let instances: Map<any, Base>;
let summaries: () => any[];
@ -138,6 +138,7 @@ import {fixmeIvy} from '@angular/private/testing';
afterEach(() => { resetTestEnvironmentWithSummaries(); });
fixmeIvy('FW-514: ngSummary shims not generated by ngtsc') &&
it('should use directive metadata from summaries', () => {
resetTestEnvironmentWithSummaries(summaries);
@ -146,11 +147,13 @@ import {fixmeIvy} from '@angular/private/testing';
}
TestBed
.configureTestingModule({providers: [SomeDep], declarations: [TestComp, SomeDirective]})
.configureTestingModule(
{providers: [SomeDep], declarations: [TestComp, SomeDirective]})
.createComponent(TestComp);
expectInstanceCreated(SomeDirective);
});
fixmeIvy('FW-514: ngSummary shims not generated by ngtsc') &&
it('should use pipe metadata from summaries', () => {
resetTestEnvironmentWithSummaries(summaries);
@ -163,6 +166,7 @@ import {fixmeIvy} from '@angular/private/testing';
expectInstanceCreated(SomePipe);
});
fixmeIvy('FW-514: ngSummary shims not generated by ngtsc') &&
it('should use Service metadata from summaries', () => {
resetTestEnvironmentWithSummaries(summaries);
@ -173,6 +177,7 @@ import {fixmeIvy} from '@angular/private/testing';
expectInstanceCreated(SomeService);
});
fixmeIvy('FW-514: ngSummary shims not generated by ngtsc') &&
it('should use NgModule metadata from summaries', () => {
resetTestEnvironmentWithSummaries(summaries);
@ -187,6 +192,7 @@ import {fixmeIvy} from '@angular/private/testing';
expectInstanceCreated(SomeService);
});
fixmeIvy('FW-514: ngSummary shims not generated by ngtsc') &&
it('should allow to create private components from imported NgModule summaries', () => {
resetTestEnvironmentWithSummaries(summaries);
@ -195,11 +201,13 @@ import {fixmeIvy} from '@angular/private/testing';
expectInstanceCreated(SomePrivateComponent);
});
fixmeIvy('FW-514: ngSummary shims not generated by ngtsc') &&
it('should throw when trying to mock a type with a summary', () => {
resetTestEnvironmentWithSummaries(summaries);
TestBed.resetTestingModule();
expect(() => TestBed.overrideComponent(SomePrivateComponent, {add: {}}).compileComponents())
expect(
() => TestBed.overrideComponent(SomePrivateComponent, {add: {}}).compileComponents())
.toThrowError(
'SomePrivateComponent was AOT compiled, so its metadata cannot be changed.');
TestBed.resetTestingModule();
@ -213,11 +221,13 @@ import {fixmeIvy} from '@angular/private/testing';
.toThrowError('SomeModule was AOT compiled, so its metadata cannot be changed.');
});
fixmeIvy('FW-514: ngSummary shims not generated by ngtsc') &&
it('should return stack trace and component data on resetTestingModule when error is thrown',
() => {
resetTestEnvironmentWithSummaries();
const fixture = TestBed.configureTestingModule({declarations: [TestCompErrorOnDestroy]})
const fixture =
TestBed.configureTestingModule({declarations: [TestCompErrorOnDestroy]})
.createComponent<TestCompErrorOnDestroy>(TestCompErrorOnDestroy);
const expectedError = 'Error from ngOnDestroy';
@ -238,6 +248,7 @@ import {fixmeIvy} from '@angular/private/testing';
.toHaveBeenCalledWith('Error during cleanup of component', expectedObject);
});
fixmeIvy('FW-514: ngSummary shims not generated by ngtsc') &&
it('should allow to add summaries via configureTestingModule', () => {
resetTestEnvironmentWithSummaries();
@ -255,6 +266,7 @@ import {fixmeIvy} from '@angular/private/testing';
expectInstanceCreated(SomeDirective);
});
fixmeIvy('FW-514: ngSummary shims not generated by ngtsc') &&
it('should allow to override a provider', () => {
resetTestEnvironmentWithSummaries(summaries);
@ -268,12 +280,14 @@ import {fixmeIvy} from '@angular/private/testing';
expect(fixture.componentInstance.dep).toBe(overwrittenValue);
});
fixmeIvy('FW-514: ngSummary shims not generated by ngtsc') &&
it('should allow to override a template', () => {
resetTestEnvironmentWithSummaries(summaries);
TestBed.overrideTemplateUsingTestingModule(SomePublicComponent, 'overwritten');
const fixture = TestBed.configureTestingModule({providers: [SomeDep], imports: [SomeModule]})
const fixture =
TestBed.configureTestingModule({providers: [SomeDep], imports: [SomeModule]})
.createComponent(SomePublicComponent);
expectInstanceCreated(SomePublicComponent);

View File

@ -15,7 +15,7 @@ import {Subject} from 'rxjs';
import {stringify} from '../../src/util';
// FW-670: Internal Error: The name q is already defined in scope
fixmeIvy('FW-670') && describe('Query API', () => {
describe('Query API', () => {
beforeEach(() => TestBed.configureTestingModule({
declarations: [
@ -54,6 +54,7 @@ fixmeIvy('FW-670') && describe('Query API', () => {
}));
describe('querying by directive type', () => {
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should contain all direct child directives in the light dom (constructor)', () => {
const template = '<div text="1"></div>' +
'<needs-query text="2"><div text="3">' +
@ -65,8 +66,10 @@ fixmeIvy('FW-670') && describe('Query API', () => {
expect(asNativeElements(view.debugElement.children)).toHaveText('2|3|');
});
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should contain all direct child directives in the content dom', () => {
const template = '<needs-content-children #q><div text="foo"></div></needs-content-children>';
const template =
'<needs-content-children #q><div text="foo"></div></needs-content-children>';
const view = createTestCmpAndDetectChanges(MyComp0, template);
const q = view.debugElement.children[0].references !['q'];
@ -75,6 +78,7 @@ fixmeIvy('FW-670') && describe('Query API', () => {
expect(q.numberOfChildrenAfterContentInit).toEqual(1);
});
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should contain the first content child', () => {
const template =
'<needs-content-child #q><div *ngIf="shouldShow" text="foo"></div></needs-content-child>';
@ -87,10 +91,12 @@ fixmeIvy('FW-670') && describe('Query API', () => {
view.componentInstance.shouldShow = false;
view.detectChanges();
expect(q.logs).toEqual([
['setter', 'foo'], ['init', 'foo'], ['check', 'foo'], ['setter', null], ['check', null]
['setter', 'foo'], ['init', 'foo'], ['check', 'foo'], ['setter', null],
['check', null]
]);
});
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should contain the first content child when target is on <ng-template> with embedded view (issue #16568)',
() => {
const template =
@ -105,6 +111,7 @@ fixmeIvy('FW-670') && describe('Query API', () => {
expect(directive.child.text).toEqual('foo');
});
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should contain the first view child', () => {
const template = '<needs-view-child #q></needs-view-child>';
const view = createTestCmpAndDetectChanges(MyComp0, template);
@ -115,10 +122,12 @@ fixmeIvy('FW-670') && describe('Query API', () => {
q.shouldShow = false;
view.detectChanges();
expect(q.logs).toEqual([
['setter', 'foo'], ['init', 'foo'], ['check', 'foo'], ['setter', null], ['check', null]
['setter', 'foo'], ['init', 'foo'], ['check', 'foo'], ['setter', null],
['check', null]
]);
});
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should set static view and content children already after the constructor call', () => {
const template =
'<needs-static-content-view-child #q><div text="contentFoo"></div></needs-static-content-view-child>';
@ -132,6 +141,7 @@ fixmeIvy('FW-670') && describe('Query API', () => {
expect(q.viewChild.text).toEqual('viewFoo');
});
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should contain the first view child across embedded views', () => {
TestBed.overrideComponent(
MyComp0, {set: {template: '<needs-view-child #q></needs-view-child>'}});
@ -160,6 +170,7 @@ fixmeIvy('FW-670') && describe('Query API', () => {
expect(q.logs).toEqual([['setter', null], ['check', null]]);
});
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should contain all directives in the light dom when descendants flag is used', () => {
const template = '<div text="1"></div>' +
'<needs-query-desc text="2"><div text="3">' +
@ -171,6 +182,7 @@ fixmeIvy('FW-670') && describe('Query API', () => {
expect(asNativeElements(view.debugElement.children)).toHaveText('2|3|4|');
});
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should contain all directives in the light dom', () => {
const template = '<div text="1"></div>' +
'<needs-query text="2"><div text="3"></div></needs-query>' +
@ -180,6 +192,7 @@ fixmeIvy('FW-670') && describe('Query API', () => {
expect(asNativeElements(view.debugElement.children)).toHaveText('2|3|');
});
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should reflect dynamically inserted directives', () => {
const template = '<div text="1"></div>' +
'<needs-query text="2"><div *ngIf="shouldShow" [text]="\'3\'"></div></needs-query>' +
@ -192,6 +205,7 @@ fixmeIvy('FW-670') && describe('Query API', () => {
expect(asNativeElements(view.debugElement.children)).toHaveText('2|3|');
});
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should be cleanly destroyed when a query crosses view boundaries', () => {
const template = '<div text="1"></div>' +
'<needs-query text="2"><div *ngIf="shouldShow" [text]="\'3\'"></div></needs-query>' +
@ -203,6 +217,7 @@ fixmeIvy('FW-670') && describe('Query API', () => {
view.destroy();
});
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should reflect moved directives', () => {
const template = '<div text="1"></div>' +
'<needs-query text="2"><div *ngFor="let i of list" [text]="i"></div></needs-query>' +
@ -215,6 +230,7 @@ fixmeIvy('FW-670') && describe('Query API', () => {
expect(asNativeElements(view.debugElement.children)).toHaveText('2|3d|2d|');
});
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should throw with descriptive error when query selectors are not present', () => {
TestBed.configureTestingModule({declarations: [MyCompBroken0, HasNullQueryCondition]});
const template = '<has-null-query-condition></has-null-query-condition>';
@ -226,27 +242,33 @@ fixmeIvy('FW-670') && describe('Query API', () => {
});
describe('query for TemplateRef', () => {
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should find TemplateRefs in the light and shadow dom', () => {
const template = '<needs-tpl><ng-template><div>light</div></ng-template></needs-tpl>';
const view = createTestCmpAndDetectChanges(MyComp0, template);
const needsTpl: NeedsTpl = view.debugElement.children[0].injector.get(NeedsTpl);
expect(needsTpl.vc.createEmbeddedView(needsTpl.query.first).rootNodes[0]).toHaveText('light');
expect(needsTpl.vc.createEmbeddedView(needsTpl.query.first).rootNodes[0])
.toHaveText('light');
expect(needsTpl.vc.createEmbeddedView(needsTpl.viewQuery.first).rootNodes[0])
.toHaveText('shadow');
});
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should find named TemplateRefs', () => {
const template =
'<needs-named-tpl><ng-template #tpl><div>light</div></ng-template></needs-named-tpl>';
const view = createTestCmpAndDetectChanges(MyComp0, template);
const needsTpl: NeedsNamedTpl = view.debugElement.children[0].injector.get(NeedsNamedTpl);
expect(needsTpl.vc.createEmbeddedView(needsTpl.contentTpl).rootNodes[0]).toHaveText('light');
expect(needsTpl.vc.createEmbeddedView(needsTpl.viewTpl).rootNodes[0]).toHaveText('shadow');
expect(needsTpl.vc.createEmbeddedView(needsTpl.contentTpl).rootNodes[0])
.toHaveText('light');
expect(needsTpl.vc.createEmbeddedView(needsTpl.viewTpl).rootNodes[0])
.toHaveText('shadow');
});
});
describe('read a different token', () => {
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should contain all content children', () => {
const template =
'<needs-content-children-read #q text="ca"><div #q text="cb"></div></needs-content-children-read>';
@ -254,9 +276,12 @@ fixmeIvy('FW-670') && describe('Query API', () => {
const comp: NeedsContentChildrenWithRead =
view.debugElement.children[0].injector.get(NeedsContentChildrenWithRead);
expect(comp.textDirChildren.map(textDirective => textDirective.text)).toEqual(['ca', 'cb']);
expect(comp.textDirChildren.map(textDirective => textDirective.text)).toEqual([
'ca', 'cb'
]);
});
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should contain the first content child', () => {
const template =
'<needs-content-child-read><div #q text="ca"></div></needs-content-child-read>';
@ -267,6 +292,7 @@ fixmeIvy('FW-670') && describe('Query API', () => {
expect(comp.textDirChild.text).toEqual('ca');
});
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should contain the first descendant content child', () => {
const template = '<needs-content-child-read>' +
'<div dir><div #q text="ca"></div></div>' +
@ -278,6 +304,7 @@ fixmeIvy('FW-670') && describe('Query API', () => {
expect(comp.textDirChild.text).toEqual('ca');
});
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should contain the first descendant content child templateRef', () => {
const template = '<needs-content-child-template-ref-app>' +
'</needs-content-child-template-ref-app>';
@ -300,6 +327,7 @@ fixmeIvy('FW-670') && describe('Query API', () => {
expect(view.nativeElement).toHaveText('OUTER');
});
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should contain the first view child', () => {
const template = '<needs-view-child-read></needs-view-child-read>';
const view = createTestCmpAndDetectChanges(MyComp0, template);
@ -309,15 +337,19 @@ fixmeIvy('FW-670') && describe('Query API', () => {
expect(comp.textDirChild.text).toEqual('va');
});
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should contain all child directives in the view', () => {
const template = '<needs-view-children-read></needs-view-children-read>';
const view = createTestCmpAndDetectChanges(MyComp0, template);
const comp: NeedsViewChildrenWithRead =
view.debugElement.children[0].injector.get(NeedsViewChildrenWithRead);
expect(comp.textDirChildren.map(textDirective => textDirective.text)).toEqual(['va', 'vb']);
expect(comp.textDirChildren.map(textDirective => textDirective.text)).toEqual([
'va', 'vb'
]);
});
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should support reading a ViewContainer', () => {
const template =
'<needs-viewcontainer-read><ng-template>hello</ng-template></needs-viewcontainer-read>';
@ -331,6 +363,7 @@ fixmeIvy('FW-670') && describe('Query API', () => {
});
describe('changes', () => {
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should notify query on change', async(() => {
const template = '<needs-query #q>' +
'<div text="1"></div>' +
@ -351,9 +384,11 @@ fixmeIvy('FW-670') && describe('Query API', () => {
view.detectChanges();
}));
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should correctly clean-up when destroyed together with the directives it is querying',
() => {
const template = '<needs-query #q *ngIf="shouldShow"><div text="foo"></div></needs-query>';
const template =
'<needs-query #q *ngIf="shouldShow"><div text="foo"></div></needs-query>';
const view = createTestCmpAndDetectChanges(MyComp0, template);
view.componentInstance.shouldShow = true;
view.detectChanges();
@ -382,6 +417,7 @@ fixmeIvy('FW-670') && describe('Query API', () => {
});
describe('querying by var binding', () => {
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should contain all the child directives in the light dom with the given var binding',
() => {
const template = '<needs-query-by-ref-binding #q>' +
@ -396,6 +432,7 @@ fixmeIvy('FW-670') && describe('Query API', () => {
expect(q.query.last.text).toEqual('2d');
});
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should support querying by multiple var bindings', () => {
const template = '<needs-query-by-ref-bindings #q>' +
'<div text="one" #textLabel1="textDir"></div>' +
@ -408,6 +445,7 @@ fixmeIvy('FW-670') && describe('Query API', () => {
expect(q.query.last.text).toEqual('two');
});
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should support dynamically inserted directives', () => {
const template = '<needs-query-by-ref-binding #q>' +
'<div *ngFor="let item of list" [text]="item" #textLabel="textDir"></div>' +
@ -422,6 +460,7 @@ fixmeIvy('FW-670') && describe('Query API', () => {
expect(q.query.last.text).toEqual('1d');
});
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should contain all the elements in the light dom with the given var binding', () => {
const template = '<needs-query-by-ref-binding #q>' +
'<div *ngFor="let item of list">' +
@ -437,6 +476,7 @@ fixmeIvy('FW-670') && describe('Query API', () => {
expect(q.query.last.nativeElement).toHaveText('2d');
});
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should contain all the elements in the light dom even if they get projected', () => {
const template = '<needs-query-and-project #q>' +
'<div text="hello"></div><div text="world"></div>' +
@ -446,6 +486,7 @@ fixmeIvy('FW-670') && describe('Query API', () => {
expect(asNativeElements(view.debugElement.children)).toHaveText('hello|world|');
});
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should support querying the view by using a view query', () => {
const template = '<needs-view-query-by-ref-binding #q></needs-view-query-by-ref-binding>';
const view = createTestCmpAndDetectChanges(MyComp0, template);
@ -454,6 +495,7 @@ fixmeIvy('FW-670') && describe('Query API', () => {
expect(q.query.first.nativeElement).toHaveText('text');
});
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should contain all child directives in the view dom', () => {
const template = '<needs-view-children #q></needs-view-children>';
const view = createTestCmpAndDetectChanges(MyComp0, template);
@ -464,6 +506,7 @@ fixmeIvy('FW-670') && describe('Query API', () => {
});
describe('querying in the view', () => {
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should contain all the elements in the view with that have the given directive', () => {
const template = '<needs-view-query #q><div text="ignoreme"></div></needs-view-query>';
const view = createTestCmpAndDetectChanges(MyComp0, template);
@ -471,6 +514,7 @@ fixmeIvy('FW-670') && describe('Query API', () => {
expect(q.query.map((d: TextDirective) => d.text)).toEqual(['1', '2', '3', '4']);
});
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should not include directive present on the host element', () => {
const template = '<needs-view-query #q text="self"></needs-view-query>';
const view = createTestCmpAndDetectChanges(MyComp0, template);
@ -478,6 +522,7 @@ fixmeIvy('FW-670') && describe('Query API', () => {
expect(q.query.map((d: TextDirective) => d.text)).toEqual(['1', '2', '3', '4']);
});
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should reflect changes in the component', () => {
const template = '<needs-view-query-if #q></needs-view-query-if>';
const view = createTestCmpAndDetectChanges(MyComp0, template);
@ -490,6 +535,7 @@ fixmeIvy('FW-670') && describe('Query API', () => {
expect(q.query.first.text).toEqual('1');
});
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should not be affected by other changes in the component', () => {
const template = '<needs-view-query-nested-if #q></needs-view-query-nested-if>';
const view = createTestCmpAndDetectChanges(MyComp0, template);
@ -504,6 +550,7 @@ fixmeIvy('FW-670') && describe('Query API', () => {
expect(q.query.first.text).toEqual('1');
});
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should maintain directives in pre-order depth-first DOM order after dynamic insertion',
() => {
const template = '<needs-view-query-order #q></needs-view-query-order>';
@ -517,11 +564,13 @@ fixmeIvy('FW-670') && describe('Query API', () => {
expect(q.query.map((d: TextDirective) => d.text)).toEqual(['1', '-3', '2', '4']);
});
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should maintain directives in pre-order depth-first DOM order after dynamic insertion',
() => {
const template = '<needs-view-query-order-with-p #q></needs-view-query-order-with-p>';
const view = createTestCmpAndDetectChanges(MyComp0, template);
const q: NeedsViewQueryOrderWithParent = view.debugElement.children[0].references !['q'];
const q: NeedsViewQueryOrderWithParent =
view.debugElement.children[0].references !['q'];
expect(q.query.map((d: TextDirective) => d.text)).toEqual(['1', '2', '3', '4']);
q.list = ['-3', '2'];
@ -529,6 +578,7 @@ fixmeIvy('FW-670') && describe('Query API', () => {
expect(q.query.map((d: TextDirective) => d.text)).toEqual(['1', '-3', '2', '4']);
});
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should handle long ngFor cycles', () => {
const template = '<needs-view-query-order #q></needs-view-query-order>';
const view = createTestCmpAndDetectChanges(MyComp0, template);
@ -551,6 +601,7 @@ fixmeIvy('FW-670') && describe('Query API', () => {
}
});
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should support more than three queries', () => {
const template = '<needs-four-queries #q><div text="1"></div></needs-four-queries>';
const view = createTestCmpAndDetectChanges(MyComp0, template);
@ -563,6 +614,7 @@ fixmeIvy('FW-670') && describe('Query API', () => {
});
describe('query over moved templates', () => {
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should include manually projected templates in queries', () => {
const template =
'<manual-projecting #q><ng-template><div text="1"></div></ng-template></manual-projecting>';
@ -594,6 +646,7 @@ fixmeIvy('FW-670') && describe('Query API', () => {
// for
// performance
// reasons.
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should not affected queries for projected templates if views are detached or moved', () => {
const template =
'<manual-projecting #q><ng-template let-x="x"><div [text]="x"></div></ng-template></manual-projecting>';
@ -619,6 +672,7 @@ fixmeIvy('FW-670') && describe('Query API', () => {
expect(q.query.map((d: TextDirective) => d.text)).toEqual(['1', '2']);
});
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should remove manually projected templates if their parent view is destroyed', () => {
const template = `
<manual-projecting #q><ng-template #tpl><div text="1"></div></ng-template></manual-projecting>
@ -638,6 +692,7 @@ fixmeIvy('FW-670') && describe('Query API', () => {
expect(q.query.length).toBe(0);
});
fixmeIvy('FW-670: Internal Error: The name q is already defined in scope') &&
it('should not throw if a content template is queried and created in the view during change detection',
() => {
@Component(

View File

@ -14,7 +14,7 @@ import {fixmeIvy} from '@angular/private/testing';
{
if (ivyEnabled) {
fixmeIvy('unknown') && describe('ivy', () => { declareTests(); });
describe('ivy', () => { declareTests(); });
} else {
describe('jit', () => { declareTests({useJit: true}); });
describe('no jit', () => { declareTests({useJit: false}); });
@ -52,7 +52,7 @@ function declareTests(config?: {useJit: boolean}) {
afterEach(() => { getDOM().log = originalLog; });
describe('events', () => {
it('should disallow binding to attr.on*', () => {
fixmeIvy('unknown') && it('should disallow binding to attr.on*', () => {
const template = `<div [attr.onclick]="ctxProp"></div>`;
TestBed.overrideComponent(SecuredComponent, {set: {template}});
@ -61,7 +61,7 @@ function declareTests(config?: {useJit: boolean}) {
/Binding to event attribute 'onclick' is disallowed for security reasons, please use \(click\)=.../);
});
it('should disallow binding to on* with NO_ERRORS_SCHEMA', () => {
fixmeIvy('unknown') && it('should disallow binding to on* with NO_ERRORS_SCHEMA', () => {
const template = `<div [onclick]="ctxProp"></div>`;
TestBed.overrideComponent(SecuredComponent, {set: {template}}).configureTestingModule({
schemas: [NO_ERRORS_SCHEMA]
@ -72,6 +72,7 @@ function declareTests(config?: {useJit: boolean}) {
/Binding to event property 'onclick' is disallowed for security reasons, please use \(click\)=.../);
});
fixmeIvy('unknown') &&
it('should disallow binding to on* unless it is consumed by a directive', () => {
const template = `<div [onPrefixedProp]="ctxProp" [onclick]="ctxProp"></div>`;
TestBed.overrideComponent(SecuredComponent, {set: {template}}).configureTestingModule({
@ -94,7 +95,7 @@ function declareTests(config?: {useJit: boolean}) {
});
describe('safe HTML values', function() {
it('should not escape values marked as trusted', () => {
fixmeIvy('unknown') && it('should not escape values marked as trusted', () => {
const template = `<a [href]="ctxProp">Link Title</a>`;
TestBed.overrideComponent(SecuredComponent, {set: {template}});
const fixture = TestBed.createComponent(SecuredComponent);
@ -108,7 +109,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(getDOM().getProperty(e, 'href')).toEqual('javascript:alert(1)');
});
it('should error when using the wrong trusted value', () => {
fixmeIvy('unknown') && it('should error when using the wrong trusted value', () => {
const template = `<a [href]="ctxProp">Link Title</a>`;
TestBed.overrideComponent(SecuredComponent, {set: {template}});
const fixture = TestBed.createComponent(SecuredComponent);
@ -120,7 +121,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(() => fixture.detectChanges()).toThrowError(/Required a safe URL, got a Script/);
});
it('should warn when using in string interpolation', () => {
fixmeIvy('unknown') && it('should warn when using in string interpolation', () => {
const template = `<a href="/foo/{{ctxProp}}">Link Title</a>`;
TestBed.overrideComponent(SecuredComponent, {set: {template}});
const fixture = TestBed.createComponent(SecuredComponent);
@ -153,7 +154,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(value).toEqual('unsafe:javascript:alert(1)');
}
it('should escape unsafe properties', () => {
fixmeIvy('unknown') && it('should escape unsafe properties', () => {
const template = `<a [href]="ctxProp">Link Title</a>`;
TestBed.overrideComponent(SecuredComponent, {set: {template}});
const fixture = TestBed.createComponent(SecuredComponent);
@ -161,7 +162,7 @@ function declareTests(config?: {useJit: boolean}) {
checkEscapeOfHrefProperty(fixture, false);
});
it('should escape unsafe attributes', () => {
fixmeIvy('unknown') && it('should escape unsafe attributes', () => {
const template = `<a [attr.href]="ctxProp">Link Title</a>`;
TestBed.overrideComponent(SecuredComponent, {set: {template}});
const fixture = TestBed.createComponent(SecuredComponent);
@ -169,6 +170,7 @@ function declareTests(config?: {useJit: boolean}) {
checkEscapeOfHrefProperty(fixture, true);
});
fixmeIvy('unknown') &&
it('should escape unsafe properties if they are used in host bindings', () => {
@Directive({selector: '[dirHref]'})
class HrefDirective {
@ -185,6 +187,7 @@ function declareTests(config?: {useJit: boolean}) {
checkEscapeOfHrefProperty(fixture, false);
});
fixmeIvy('unknown') &&
it('should escape unsafe attributes if they are used in host bindings', () => {
@Directive({selector: '[dirHref]'})
class HrefDirective {
@ -201,7 +204,7 @@ function declareTests(config?: {useJit: boolean}) {
checkEscapeOfHrefProperty(fixture, true);
});
it('should escape unsafe style values', () => {
fixmeIvy('unknown') && it('should escape unsafe style values', () => {
const template = `<div [style.background]="ctxProp">Text</div>`;
TestBed.overrideComponent(SecuredComponent, {set: {template}});
const fixture = TestBed.createComponent(SecuredComponent);
@ -221,7 +224,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(getDOM().getStyle(e, 'background')).not.toContain('javascript');
});
it('should escape unsafe SVG attributes', () => {
fixmeIvy('unknown') && it('should escape unsafe SVG attributes', () => {
const template = `<svg:circle [xlink:href]="ctxProp">Text</svg:circle>`;
TestBed.overrideComponent(SecuredComponent, {set: {template}});
@ -229,7 +232,7 @@ function declareTests(config?: {useJit: boolean}) {
.toThrowError(/Can't bind to 'xlink:href'/);
});
it('should escape unsafe HTML values', () => {
fixmeIvy('unknown') && it('should escape unsafe HTML values', () => {
const template = `<div [innerHTML]="ctxProp">Text</div>`;
TestBed.overrideComponent(SecuredComponent, {set: {template}});
const fixture = TestBed.createComponent(SecuredComponent);

View File

@ -16,7 +16,7 @@ import {TestBed, fakeAsync, tick} from '@angular/core/testing';
import {fixmeIvy} from '@angular/private/testing';
{
fixmeIvy('unknown') && describe('jit source mapping', () => {
describe('jit source mapping', () => {
let jitSpy: jasmine.Spy;
let resourceLoader: MockResourceLoader;
@ -102,27 +102,29 @@ import {fixmeIvy} from '@angular/private/testing';
function declareTests(
{ngUrl, templateDecorator}:
{ngUrl: string, templateDecorator: (template: string) => { [key: string]: any }}) {
fixmeIvy('unknown') &&
it('should use the right source url in html parse errors', fakeAsync(() => {
@Component({...templateDecorator('<div>\n </error>')})
class MyComp {
}
expect(() => compileAndCreateComponent(MyComp))
.toThrowError(
new RegExp(`Template parse errors[\\s\\S]*${ngUrl.replace('$', '\\$')}@1:2`));
.toThrowError(new RegExp(
`Template parse errors[\\s\\S]*${ngUrl.replace('$', '\\$')}@1:2`));
}));
fixmeIvy('unknown') &&
it('should use the right source url in template parse errors', fakeAsync(() => {
@Component({...templateDecorator('<div>\n <div unknown="{{ctxProp}}"></div>')})
class MyComp {
}
expect(() => compileAndCreateComponent(MyComp))
.toThrowError(
new RegExp(`Template parse errors[\\s\\S]*${ngUrl.replace('$', '\\$')}@1:7`));
.toThrowError(new RegExp(
`Template parse errors[\\s\\S]*${ngUrl.replace('$', '\\$')}@1:7`));
}));
it('should create a sourceMap for templates', fakeAsync(() => {
fixmeIvy('unknown') && it('should create a sourceMap for templates', fakeAsync(() => {
const template = `Hello World!`;
@Component({...templateDecorator(template)})
@ -131,7 +133,8 @@ import {fixmeIvy} from '@angular/private/testing';
compileAndCreateComponent(MyComp);
const sourceMap = getSourceMap('ng:///DynamicTestModule/MyComp.ngfactory.js');
const sourceMap =
getSourceMap('ng:///DynamicTestModule/MyComp.ngfactory.js');
expect(sourceMap.sources).toEqual([
'ng:///DynamicTestModule/MyComp.ngfactory.js', ngUrl
]);
@ -139,6 +142,7 @@ import {fixmeIvy} from '@angular/private/testing';
}));
fixmeIvy('unknown') &&
it('should report source location for di errors', fakeAsync(() => {
const template = `<div>\n <div someDir></div></div>`;
@ -166,6 +170,7 @@ import {fixmeIvy} from '@angular/private/testing';
});
}));
fixmeIvy('unknown') &&
it('should report di errors with multiple elements and directives', fakeAsync(() => {
const template = `<div someDir></div><div someDir="throw"></div>`;
@ -197,6 +202,7 @@ import {fixmeIvy} from '@angular/private/testing';
});
}));
fixmeIvy('unknown') &&
it('should report source location for binding errors', fakeAsync(() => {
const template = `<div>\n <span [title]="createError()"></span></div>`;
@ -227,6 +233,7 @@ import {fixmeIvy} from '@angular/private/testing';
});
}));
fixmeIvy('unknown') &&
it('should report source location for event errors', fakeAsync(() => {
const template = `<div>\n <span (click)="createError()"></span></div>`;

View File

@ -1564,7 +1564,7 @@ describe('ViewContainerRef', () => {
});
});
fixmeIvy(`Hooks don't run`) && describe('life cycle hooks', () => {
describe('life cycle hooks', () => {
// Angular 5 reference: https://stackblitz.com/edit/lifecycle-hooks-vcref
const log: string[] = [];
@ -1608,6 +1608,7 @@ describe('ViewContainerRef', () => {
});
}
fixmeIvy(`Hooks don't run`) &&
it('should call all hooks in correct order when creating with createEmbeddedView', () => {
function SomeComponent_Template_0(rf: RenderFlags, ctx: any) {
if (rf & RenderFlags.Create) {
@ -1637,7 +1638,8 @@ describe('ViewContainerRef', () => {
template: (rf: RenderFlags, cmp: SomeComponent) => {
if (rf & RenderFlags.Create) {
template(
0, SomeComponent_Template_0, 1, 1, null, [], ['foo', ''], templateRefExtractor);
0, SomeComponent_Template_0, 1, 1, null, [], ['foo', ''],
templateRefExtractor);
element(2, 'hooks', ['vcref', '']);
element(3, 'hooks');
}
@ -1670,7 +1672,8 @@ describe('ViewContainerRef', () => {
]);
log.length = 0;
directiveInstance !.vcref.createEmbeddedView(directiveInstance !.tplRef, fixture.component);
directiveInstance !.vcref.createEmbeddedView(
directiveInstance !.tplRef, fixture.component);
expect(fixture.html).toEqual('<hooks vcref="">A</hooks><hooks></hooks><hooks>B</hooks>');
expect(log).toEqual([]);
@ -1679,15 +1682,17 @@ describe('ViewContainerRef', () => {
expect(fixture.html).toEqual('<hooks vcref="">A</hooks><hooks>C</hooks><hooks>B</hooks>');
expect(log).toEqual([
'doCheck-A', 'doCheck-B', 'onChanges-C', 'onInit-C', 'doCheck-C', 'afterContentInit-C',
'afterContentChecked-C', 'afterViewInit-C', 'afterViewChecked-C', 'afterContentChecked-A',
'afterContentChecked-B', 'afterViewChecked-A', 'afterViewChecked-B'
'afterContentChecked-C', 'afterViewInit-C', 'afterViewChecked-C',
'afterContentChecked-A', 'afterContentChecked-B', 'afterViewChecked-A',
'afterViewChecked-B'
]);
log.length = 0;
fixture.update();
expect(log).toEqual([
'doCheck-A', 'doCheck-B', 'doCheck-C', 'afterContentChecked-C', 'afterViewChecked-C',
'afterContentChecked-A', 'afterContentChecked-B', 'afterViewChecked-A', 'afterViewChecked-B'
'afterContentChecked-A', 'afterContentChecked-B', 'afterViewChecked-A',
'afterViewChecked-B'
]);
log.length = 0;
@ -1703,18 +1708,20 @@ describe('ViewContainerRef', () => {
fixture.update();
expect(log).toEqual([
'doCheck-A', 'doCheck-B', 'doCheck-C', 'afterContentChecked-C', 'afterViewChecked-C',
'afterContentChecked-A', 'afterContentChecked-B', 'afterViewChecked-A', 'afterViewChecked-B'
'afterContentChecked-A', 'afterContentChecked-B', 'afterViewChecked-A',
'afterViewChecked-B'
]);
log.length = 0;
directiveInstance !.vcref.remove(0);
fixture.update();
expect(log).toEqual([
'onDestroy-C', 'doCheck-A', 'doCheck-B', 'afterContentChecked-A', 'afterContentChecked-B',
'afterViewChecked-A', 'afterViewChecked-B'
'onDestroy-C', 'doCheck-A', 'doCheck-B', 'afterContentChecked-A',
'afterContentChecked-B', 'afterViewChecked-A', 'afterViewChecked-B'
]);
});
fixmeIvy(`Hooks don't run`) &&
it('should call all hooks in correct order when creating with createComponent', () => {
@Component({
template: `
@ -1773,15 +1780,17 @@ describe('ViewContainerRef', () => {
expect(fixture.html).toEqual('<hooks vcref="">A</hooks><hooks>D</hooks><hooks>B</hooks>');
expect(log).toEqual([
'doCheck-A', 'doCheck-B', 'onChanges-D', 'onInit-D', 'doCheck-D', 'afterContentInit-D',
'afterContentChecked-D', 'afterViewInit-D', 'afterViewChecked-D', 'afterContentChecked-A',
'afterContentChecked-B', 'afterViewChecked-A', 'afterViewChecked-B'
'afterContentChecked-D', 'afterViewInit-D', 'afterViewChecked-D',
'afterContentChecked-A', 'afterContentChecked-B', 'afterViewChecked-A',
'afterViewChecked-B'
]);
log.length = 0;
fixture.update();
expect(log).toEqual([
'doCheck-A', 'doCheck-B', 'doCheck-D', 'afterContentChecked-D', 'afterViewChecked-D',
'afterContentChecked-A', 'afterContentChecked-B', 'afterViewChecked-A', 'afterViewChecked-B'
'afterContentChecked-A', 'afterContentChecked-B', 'afterViewChecked-A',
'afterViewChecked-B'
]);
log.length = 0;
@ -1797,15 +1806,16 @@ describe('ViewContainerRef', () => {
fixture.update();
expect(log).toEqual([
'doCheck-A', 'doCheck-B', 'doCheck-D', 'afterContentChecked-D', 'afterViewChecked-D',
'afterContentChecked-A', 'afterContentChecked-B', 'afterViewChecked-A', 'afterViewChecked-B'
'afterContentChecked-A', 'afterContentChecked-B', 'afterViewChecked-A',
'afterViewChecked-B'
]);
log.length = 0;
directiveInstance !.vcref.remove(0);
fixture.update();
expect(log).toEqual([
'onDestroy-D', 'doCheck-A', 'doCheck-B', 'afterContentChecked-A', 'afterContentChecked-B',
'afterViewChecked-A', 'afterViewChecked-B'
'onDestroy-D', 'doCheck-A', 'doCheck-B', 'afterContentChecked-A',
'afterContentChecked-B', 'afterViewChecked-A', 'afterViewChecked-B'
]);
});
});

View File

@ -114,10 +114,10 @@ import {fixmeIvy} from '@angular/private/testing';
expect(debugCtx.nodeIndex).toBe(1);
});
fixmeIvy('unknown') && describe('deps', () => {
describe('deps', () => {
class Dep {}
it('should inject deps from the same element', () => {
fixmeIvy('unknown') && it('should inject deps from the same element', () => {
createAndGetRootNodes(compViewDef([
elementDef(0, NodeFlags.None, null, null, 2, 'span'),
directiveDef(1, NodeFlags.None, null, 0, Dep, []),
@ -127,7 +127,7 @@ import {fixmeIvy} from '@angular/private/testing';
expect(instance.dep instanceof Dep).toBeTruthy();
});
it('should inject deps from a parent element', () => {
fixmeIvy('unknown') && it('should inject deps from a parent element', () => {
createAndGetRootNodes(compViewDef([
elementDef(0, NodeFlags.None, null, null, 3, 'span'),
directiveDef(1, NodeFlags.None, null, 0, Dep, []),
@ -138,7 +138,7 @@ import {fixmeIvy} from '@angular/private/testing';
expect(instance.dep instanceof Dep).toBeTruthy();
});
it('should not inject deps from sibling root elements', () => {
fixmeIvy('unknown') && it('should not inject deps from sibling root elements', () => {
const rootElNodes = [
elementDef(0, NodeFlags.None, null, null, 1, 'span'),
directiveDef(1, NodeFlags.None, null, 0, Dep, []),
@ -167,7 +167,7 @@ import {fixmeIvy} from '@angular/private/testing';
' NullInjectorError: No provider for Dep!');
});
it('should inject from a parent element in a parent view', () => {
fixmeIvy('unknown') && it('should inject from a parent element in a parent view', () => {
createAndGetRootNodes(compViewDef([
elementDef(
0, NodeFlags.None, null, null, 1, 'div', null, null, null, null,
@ -181,7 +181,7 @@ import {fixmeIvy} from '@angular/private/testing';
expect(instance.dep instanceof Dep).toBeTruthy();
});
it('should throw for missing dependencies', () => {
fixmeIvy('unknown') && it('should throw for missing dependencies', () => {
expect(() => createAndGetRootNodes(compViewDef([
elementDef(0, NodeFlags.None, null, null, 1, 'span'),
directiveDef(1, NodeFlags.None, null, 0, SomeService, ['nonExistingDep'])
@ -192,7 +192,7 @@ import {fixmeIvy} from '@angular/private/testing';
' NullInjectorError: No provider for nonExistingDep!');
});
it('should use null for optional missing dependencies', () => {
fixmeIvy('unknown') && it('should use null for optional missing dependencies', () => {
createAndGetRootNodes(compViewDef([
elementDef(0, NodeFlags.None, null, null, 1, 'span'),
directiveDef(
@ -202,7 +202,7 @@ import {fixmeIvy} from '@angular/private/testing';
expect(instance.dep).toBe(null);
});
it('should skip the current element when using SkipSelf', () => {
fixmeIvy('unknown') && it('should skip the current element when using SkipSelf', () => {
createAndGetRootNodes(compViewDef([
elementDef(0, NodeFlags.None, null, null, 4, 'span'),
providerDef(NodeFlags.TypeValueProvider, null, 'someToken', 'someParentValue', []),
@ -214,6 +214,7 @@ import {fixmeIvy} from '@angular/private/testing';
expect(instance.dep).toBe('someParentValue');
});
fixmeIvy('unknown') &&
it('should ask the root injector',
withModule({providers: [{provide: 'rootDep', useValue: 'rootValue'}]}, () => {
createAndGetRootNodes(compViewDef([
@ -225,7 +226,7 @@ import {fixmeIvy} from '@angular/private/testing';
}));
describe('builtin tokens', () => {
it('should inject ViewContainerRef', () => {
fixmeIvy('unknown') && it('should inject ViewContainerRef', () => {
createAndGetRootNodes(compViewDef([
anchorDef(NodeFlags.EmbeddedViews, null, null, 1),
directiveDef(1, NodeFlags.None, null, 0, SomeService, [ViewContainerRef]),
@ -234,7 +235,7 @@ import {fixmeIvy} from '@angular/private/testing';
expect(instance.dep.createEmbeddedView).toBeTruthy();
});
it('should inject TemplateRef', () => {
fixmeIvy('unknown') && it('should inject TemplateRef', () => {
createAndGetRootNodes(compViewDef([
anchorDef(NodeFlags.None, null, null, 1, null, compViewDefFactory([anchorDef(
NodeFlags.None, null, null, 0)])),
@ -244,7 +245,7 @@ import {fixmeIvy} from '@angular/private/testing';
expect(instance.dep.createEmbeddedView).toBeTruthy();
});
it('should inject ElementRef', () => {
fixmeIvy('unknown') && it('should inject ElementRef', () => {
const {view} = createAndGetRootNodes(compViewDef([
elementDef(0, NodeFlags.None, null, null, 1, 'span'),
directiveDef(1, NodeFlags.None, null, 0, SomeService, [ElementRef]),
@ -253,7 +254,7 @@ import {fixmeIvy} from '@angular/private/testing';
expect(instance.dep.nativeElement).toBe(asElementData(view, 0).renderElement);
});
it('should inject Injector', () => {
fixmeIvy('unknown') && it('should inject Injector', () => {
const {view} = createAndGetRootNodes(compViewDef([
elementDef(0, NodeFlags.None, null, null, 1, 'span'),
directiveDef(1, NodeFlags.None, null, 0, SomeService, [Injector]),
@ -262,6 +263,7 @@ import {fixmeIvy} from '@angular/private/testing';
expect(instance.dep.get(SomeService)).toBe(instance);
});
fixmeIvy('unknown') &&
it('should inject ChangeDetectorRef for non component providers', () => {
const {view} = createAndGetRootNodes(compViewDef([
elementDef(0, NodeFlags.None, null, null, 1, 'span'),
@ -271,6 +273,7 @@ import {fixmeIvy} from '@angular/private/testing';
expect(instance.dep._view).toBe(view);
});
fixmeIvy('unknown') &&
it('should inject ChangeDetectorRef for component providers', () => {
const {view, rootNodes} = createAndGetRootNodes(compViewDef([
elementDef(
@ -285,7 +288,7 @@ import {fixmeIvy} from '@angular/private/testing';
expect(instance.dep._view).toBe(compView);
});
it('should inject RendererV1', () => {
fixmeIvy('unknown') && it('should inject RendererV1', () => {
createAndGetRootNodes(compViewDef([
elementDef(
0, NodeFlags.None, null, null, 1, 'span', null, null, null, null,
@ -296,7 +299,7 @@ import {fixmeIvy} from '@angular/private/testing';
expect(instance.dep.createElement).toBeTruthy();
});
it('should inject Renderer2', () => {
fixmeIvy('unknown') && it('should inject Renderer2', () => {
createAndGetRootNodes(compViewDef([
elementDef(
0, NodeFlags.None, null, null, 1, 'span', null, null, null, null,