test(compiler): update examples and compiler tests (#30626)

PR Close #30626
This commit is contained in:
Kara Erickson
2019-05-22 20:42:34 -07:00
committed by Jason Aden
parent dcdecfa9a8
commit 214ae0ea4c
10 changed files with 49 additions and 43 deletions

View File

@ -27,10 +27,11 @@ import * as core from '@angular/core';
typeExtends<compilerCore.Query, core.Query>();
typeExtends<core.Query, compilerCore.Query>();
compareRuntimeShape(
new core.ContentChild('someSelector'), compilerCore.createContentChild('someSelector'));
new core.ContentChild('someSelector', {static: false}),
compilerCore.createContentChild('someSelector', {static: false}));
compareRuntimeShape(
new core.ContentChild('someSelector', {read: 'someRead'}),
compilerCore.createContentChild('someSelector', {read: 'someRead'}));
new core.ContentChild('someSelector', {read: 'someRead', static: false}),
compilerCore.createContentChild('someSelector', {read: 'someRead', static: false}));
compareRuntimeShape(
new core.ContentChildren('someSelector'),
compilerCore.createContentChildren('someSelector'));
@ -39,10 +40,11 @@ import * as core from '@angular/core';
compilerCore.createContentChildren(
'someSelector', {read: 'someRead', descendants: false}));
compareRuntimeShape(
new core.ViewChild('someSelector'), compilerCore.createViewChild('someSelector'));
new core.ViewChild('someSelector', {static: false}),
compilerCore.createViewChild('someSelector', {static: false}));
compareRuntimeShape(
new core.ViewChild('someSelector', {read: 'someRead'}),
compilerCore.createViewChild('someSelector', {read: 'someRead'}));
new core.ViewChild('someSelector', {read: 'someRead', static: false}),
compilerCore.createViewChild('someSelector', {read: 'someRead', static: false}));
compareRuntimeShape(
new core.ViewChildren('someSelector'), compilerCore.createViewChildren('someSelector'));
compareRuntimeShape(

View File

@ -68,15 +68,15 @@ class SomeDirectiveWithViewChildren {
c: any;
}
@Directive({selector: 'someDirective', queries: {'c': new ContentChild('c')}})
@Directive({selector: 'someDirective', queries: {'c': new ContentChild('c', {static: false})}})
class SomeDirectiveWithContentChild {
@ContentChild('a') a: any;
@ContentChild('a', {static: false}) a: any;
c: any;
}
@Directive({selector: 'someDirective', queries: {'c': new ViewChild('c')}})
@Directive({selector: 'someDirective', queries: {'c': new ViewChild('c', {static: false})}})
class SomeDirectiveWithViewChild {
@ViewChild('a') a: any;
@ViewChild('a', {static: false}) a: any;
c: any;
}
@ -408,37 +408,41 @@ class SomeDirectiveWithoutMetadata {}
it('should append ContentChild', () => {
const directiveMetadata = resolver.resolve(SomeDirectiveWithContentChild);
expect(directiveMetadata.queries)
.toEqual({'c': new ContentChild('c'), 'a': new ContentChild('a')});
expect(directiveMetadata.queries).toEqual({
'c': new ContentChild('c', {static: false}),
'a': new ContentChild('a', {static: false})
});
});
it('should append ViewChild', () => {
const directiveMetadata = resolver.resolve(SomeDirectiveWithViewChild);
expect(directiveMetadata.queries)
.toEqual({'c': new ViewChild('c'), 'a': new ViewChild('a')});
expect(directiveMetadata.queries).toEqual({
'c': new ViewChild('c', {static: false}),
'a': new ViewChild('a', {static: false})
});
});
it('should support inheriting queries', () => {
@Directive({selector: 'p'})
class Parent {
@ContentChild('p1')
@ContentChild('p1', {static: false})
p1: any;
@ContentChild('p21')
@ContentChild('p21', {static: false})
p2: any;
}
class Child extends Parent {
@ContentChild('p22')
@ContentChild('p22', {static: false})
p2: any;
@ContentChild('p3')
@ContentChild('p3', {static: false})
p3: any;
}
const directiveMetadata = resolver.resolve(Child);
expect(directiveMetadata.queries).toEqual({
'p1': new ContentChild('p1'),
'p2': new ContentChild('p22'),
'p3': new ContentChild('p3')
'p1': new ContentChild('p1', {static: false}),
'p2': new ContentChild('p22', {static: false}),
'p3': new ContentChild('p3', {static: false})
});
});
});