@ -68,7 +68,6 @@ import {TestBed} from '@angular/core/testing';
|
||||
view.detectChanges();
|
||||
expect(view.componentInstance.children).toBeDefined();
|
||||
expect(view.componentInstance.children.length).toBe(2);
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -77,30 +76,30 @@ import {TestBed} from '@angular/core/testing';
|
||||
@Directive({selector: 'simple'})
|
||||
class Simple {
|
||||
// TODO(issue/24571): remove '!'.
|
||||
@Input() marker !: string;
|
||||
@Input() marker!: string;
|
||||
}
|
||||
|
||||
@Component({selector: 'view-child-type-selector', template: ''})
|
||||
class ViewChildTypeSelectorComponent {
|
||||
// TODO(issue/24571): remove '!'.
|
||||
@ViewChild(Simple) child !: Simple;
|
||||
@ViewChild(Simple) child!: Simple;
|
||||
}
|
||||
|
||||
@Component({selector: 'view-child-string-selector', template: ''})
|
||||
class ViewChildStringSelectorComponent {
|
||||
// TODO(issue/24571): remove '!'.
|
||||
@ViewChild('child') child !: ElementRef;
|
||||
@ViewChild('child') child!: ElementRef;
|
||||
}
|
||||
|
||||
@Component({selector: 'view-children-type-selector', template: ''})
|
||||
class ViewChildrenTypeSelectorComponent {
|
||||
// TODO(issue/24571): remove '!'.
|
||||
@ViewChildren(Simple) children !: QueryList<Simple>;
|
||||
@ViewChildren(Simple) children!: QueryList<Simple>;
|
||||
}
|
||||
|
||||
@Component({selector: 'view-child-string-selector', template: ''})
|
||||
class ViewChildrenStringSelectorComponent {
|
||||
// Allow comma separated selector (with spaces).
|
||||
// TODO(issue/24571): remove '!'.
|
||||
@ViewChildren('child1 , child2') children !: QueryList<ElementRef>;
|
||||
@ViewChildren('child1 , child2') children!: QueryList<ElementRef>;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ describe('resource_loading', () => {
|
||||
|
||||
describe('error handling', () => {
|
||||
it('should throw an error when compiling component that has unresolved templateUrl', () => {
|
||||
const MyComponent: ComponentType<any> = (class MyComponent{}) as any;
|
||||
const MyComponent: ComponentType<any> = (class MyComponent {}) as any;
|
||||
compileComponent(MyComponent, {templateUrl: 'someUrl'});
|
||||
expect(() => MyComponent.ɵcmp).toThrowError(`
|
||||
Component 'MyComponent' is not resolved:
|
||||
@ -25,7 +25,7 @@ Did you run and wait for 'resolveComponentResources()'?`.trim());
|
||||
});
|
||||
|
||||
it('should throw an error when compiling component that has unresolved styleUrls', () => {
|
||||
const MyComponent: ComponentType<any> = (class MyComponent{}) as any;
|
||||
const MyComponent: ComponentType<any> = (class MyComponent {}) as any;
|
||||
compileComponent(MyComponent, {styleUrls: ['someUrl1', 'someUrl2']});
|
||||
expect(() => MyComponent.ɵcmp).toThrowError(`
|
||||
Component 'MyComponent' is not resolved:
|
||||
@ -35,7 +35,7 @@ Did you run and wait for 'resolveComponentResources()'?`.trim());
|
||||
|
||||
it('should throw an error when compiling component that has unresolved templateUrl and styleUrls',
|
||||
() => {
|
||||
const MyComponent: ComponentType<any> = (class MyComponent{}) as any;
|
||||
const MyComponent: ComponentType<any> = (class MyComponent {}) as any;
|
||||
compileComponent(
|
||||
MyComponent, {templateUrl: 'someUrl', styleUrls: ['someUrl1', 'someUrl2']});
|
||||
expect(() => MyComponent.ɵcmp).toThrowError(`
|
||||
@ -59,8 +59,8 @@ Did you run and wait for 'resolveComponentResources()'?`.trim());
|
||||
}
|
||||
beforeEach(() => resourceFetchCount = 0);
|
||||
|
||||
it('should resolve template', async() => {
|
||||
const MyComponent: ComponentType<any> = (class MyComponent{}) as any;
|
||||
it('should resolve template', async () => {
|
||||
const MyComponent: ComponentType<any> = (class MyComponent {}) as any;
|
||||
const metadata: Component = {templateUrl: 'test://content'};
|
||||
compileComponent(MyComponent, metadata);
|
||||
await resolveComponentResources(testResolver);
|
||||
@ -69,8 +69,8 @@ Did you run and wait for 'resolveComponentResources()'?`.trim());
|
||||
expect(resourceFetchCount).toBe(1);
|
||||
});
|
||||
|
||||
it('should resolve styleUrls', async() => {
|
||||
const MyComponent: ComponentType<any> = (class MyComponent{}) as any;
|
||||
it('should resolve styleUrls', async () => {
|
||||
const MyComponent: ComponentType<any> = (class MyComponent {}) as any;
|
||||
const metadata: Component = {template: '', styleUrls: ['test://style1', 'test://style2']};
|
||||
compileComponent(MyComponent, metadata);
|
||||
await resolveComponentResources(testResolver);
|
||||
@ -80,8 +80,8 @@ Did you run and wait for 'resolveComponentResources()'?`.trim());
|
||||
expect(resourceFetchCount).toBe(2);
|
||||
});
|
||||
|
||||
it('should cache multiple resolution to same URL', async() => {
|
||||
const MyComponent: ComponentType<any> = (class MyComponent{}) as any;
|
||||
it('should cache multiple resolution to same URL', async () => {
|
||||
const MyComponent: ComponentType<any> = (class MyComponent {}) as any;
|
||||
const metadata: Component = {template: '', styleUrls: ['test://style1', 'test://style1']};
|
||||
compileComponent(MyComponent, metadata);
|
||||
await resolveComponentResources(testResolver);
|
||||
@ -91,8 +91,8 @@ Did you run and wait for 'resolveComponentResources()'?`.trim());
|
||||
expect(resourceFetchCount).toBe(1);
|
||||
});
|
||||
|
||||
it('should keep order even if the resolution is out of order', async() => {
|
||||
const MyComponent: ComponentType<any> = (class MyComponent{}) as any;
|
||||
it('should keep order even if the resolution is out of order', async () => {
|
||||
const MyComponent: ComponentType<any> = (class MyComponent {}) as any;
|
||||
const metadata: Component = {
|
||||
template: '',
|
||||
styles: ['existing'],
|
||||
@ -113,8 +113,8 @@ Did you run and wait for 'resolveComponentResources()'?`.trim());
|
||||
});
|
||||
|
||||
it('should not add components without external resources to resolution queue', () => {
|
||||
const MyComponent: ComponentType<any> = (class MyComponent{}) as any;
|
||||
const MyComponent2: ComponentType<any> = (class MyComponent{}) as any;
|
||||
const MyComponent: ComponentType<any> = (class MyComponent {}) as any;
|
||||
const MyComponent2: ComponentType<any> = (class MyComponent {}) as any;
|
||||
|
||||
compileComponent(MyComponent, {template: ''});
|
||||
expect(isComponentResourceResolutionQueueEmpty()).toBe(true);
|
||||
@ -127,12 +127,14 @@ Did you run and wait for 'resolveComponentResources()'?`.trim());
|
||||
describe('fetch', () => {
|
||||
function fetch(url: string): Promise<Response> {
|
||||
return Promise.resolve({
|
||||
text() { return 'response for ' + url; }
|
||||
text() {
|
||||
return 'response for ' + url;
|
||||
}
|
||||
} as any as Response);
|
||||
}
|
||||
|
||||
it('should work with fetch', async() => {
|
||||
const MyComponent: ComponentType<any> = (class MyComponent{}) as any;
|
||||
it('should work with fetch', async () => {
|
||||
const MyComponent: ComponentType<any> = (class MyComponent {}) as any;
|
||||
const metadata: Component = {templateUrl: 'test://content'};
|
||||
compileComponent(MyComponent, metadata);
|
||||
await resolveComponentResources(fetch);
|
||||
|
Reference in New Issue
Block a user