Skip to content

Commit 62c68f0

Browse files
committed
test: update example apps with extra tests for downlevel constructor
1 parent 275f060 commit 62c68f0

File tree

11 files changed

+107
-12
lines changed

11 files changed

+107
-12
lines changed

e2e/ast-transformers/ng-jit-transformers/__tests__/bar.component.spec.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
import { Component } from '@angular/core';
1+
import { Component, Inject, InjectionToken } from '@angular/core';
22
import { TestBed, waitForAsync } from '@angular/core/testing';
33

4+
interface ServerError {
5+
title: string;
6+
errors: Map<string, string[]>;
7+
}
8+
9+
const DATA_TOKEN = new InjectionToken<ServerError>('DataToken');
10+
411
@Component({
512
selector: 'bar',
613
templateUrl: './bar.component.html',
@@ -14,11 +21,19 @@ import { TestBed, waitForAsync } from '@angular/core/testing';
1421
`,
1522
],
1623
})
17-
class BarComponent {}
24+
class BarComponent {
25+
constructor(@Inject(DATA_TOKEN) public data: ServerError) {}
26+
}
1827

1928
test('templateUrl/styleUrls/styles should work', waitForAsync(() => {
2029
TestBed.configureTestingModule({
2130
declarations: [BarComponent],
31+
providers: [
32+
{
33+
provide: DATA_TOKEN,
34+
useValue: {},
35+
},
36+
],
2237
});
2338
const fixture = TestBed.createComponent(BarComponent);
2439
fixture.detectChanges();

examples/example-app-monorepo/apps/app1/src/app/shared/foo.component.spec.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ComponentFixture, TestBed } from '@angular/core/testing';
22
import { REQUEST } from '@shared/app.tokens';
33

4-
import { FooComponent } from './foo.component';
4+
import { FOO_COMPONENT_DATA_TOKEN, FooComponent } from './foo.component';
55

66
describe('FooComponent', () => {
77
let fixture: ComponentFixture<FooComponent>;
@@ -13,6 +13,13 @@ describe('FooComponent', () => {
1313
provide: REQUEST,
1414
useValue: {},
1515
},
16+
{
17+
provide: FOO_COMPONENT_DATA_TOKEN,
18+
useValue: {
19+
title: '',
20+
error: new Map(),
21+
},
22+
},
1623
],
1724
}).createComponent(FooComponent);
1825
fixture.detectChanges();
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1-
import { Component, inject } from '@angular/core';
1+
import { Component, Inject, inject, InjectionToken } from '@angular/core';
22
import { Services } from '@shared/shared';
33

4+
export interface ServerError {
5+
title: string;
6+
errors: Map<string, string[]>;
7+
}
8+
9+
export const FOO_COMPONENT_DATA_TOKEN = new InjectionToken<ServerError>('FooComponentData');
10+
411
@Component({
512
template: ` <h1>Foo</h1> `,
613
standalone: true,
714
})
815
export class FooComponent {
916
private readonly appService = inject(Services.AppService);
17+
18+
constructor(@Inject(FOO_COMPONENT_DATA_TOKEN) public data: ServerError) {}
1019
}

examples/example-app-v15/src/app/shared/foo.component.spec.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ComponentFixture, TestBed } from '@angular/core/testing';
22
import { REQUEST } from '@shared/app.tokens';
33

4-
import { FooComponent } from './foo.component';
4+
import { FOO_COMPONENT_DATA_TOKEN, FooComponent } from './foo.component';
55

66
describe('FooComponent', () => {
77
let fixture: ComponentFixture<FooComponent>;
@@ -13,6 +13,13 @@ describe('FooComponent', () => {
1313
provide: REQUEST,
1414
useValue: {},
1515
},
16+
{
17+
provide: FOO_COMPONENT_DATA_TOKEN,
18+
useValue: {
19+
title: '',
20+
error: new Map(),
21+
},
22+
},
1623
],
1724
}).createComponent(FooComponent);
1825
fixture.detectChanges();
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1-
import { Component, inject } from '@angular/core';
1+
import { Component, Inject, inject, InjectionToken } from '@angular/core';
22
import { Services } from '@shared/shared';
33

4+
export interface ServerError {
5+
title: string;
6+
errors: Map<string, string[]>;
7+
}
8+
9+
export const FOO_COMPONENT_DATA_TOKEN = new InjectionToken<ServerError>('FooComponentData');
10+
411
@Component({
512
template: ` <h1>Foo</h1> `,
613
standalone: true,
714
})
815
export class FooComponent {
916
private readonly appService = inject(Services.AppService);
17+
18+
constructor(@Inject(FOO_COMPONENT_DATA_TOKEN) public data: ServerError) {}
1019
}

examples/example-app-v17/src/app/shared/foo.component.spec.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ComponentFixture, TestBed } from '@angular/core/testing';
22
import { REQUEST } from '@shared/app.tokens';
33

4-
import { FooComponent } from './foo.component';
4+
import { FOO_COMPONENT_DATA_TOKEN, FooComponent } from './foo.component';
55

66
describe('FooComponent', () => {
77
let fixture: ComponentFixture<FooComponent>;
@@ -13,6 +13,13 @@ describe('FooComponent', () => {
1313
provide: REQUEST,
1414
useValue: {},
1515
},
16+
{
17+
provide: FOO_COMPONENT_DATA_TOKEN,
18+
useValue: {
19+
title: '',
20+
error: new Map(),
21+
},
22+
},
1623
],
1724
}).createComponent(FooComponent);
1825
fixture.detectChanges();
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1-
import { Component, inject } from '@angular/core';
1+
import { Component, Inject, inject, InjectionToken } from '@angular/core';
22
import { Services } from '@shared/shared';
33

4+
export interface ServerError {
5+
title: string;
6+
errors: Map<string, string[]>;
7+
}
8+
9+
export const FOO_COMPONENT_DATA_TOKEN = new InjectionToken<ServerError>('FooComponentData');
10+
411
@Component({
512
template: ` <h1>Foo</h1> `,
613
standalone: true,
714
})
815
export class FooComponent {
916
private readonly appService = inject(Services.AppService);
17+
18+
constructor(@Inject(FOO_COMPONENT_DATA_TOKEN) public data: ServerError) {}
1019
}

examples/example-app-v18/src/app/shared/foo.component.spec.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ComponentFixture, TestBed } from '@angular/core/testing';
22
import { REQUEST } from '@shared/app.tokens';
33

4-
import { FooComponent } from './foo.component';
4+
import { FOO_COMPONENT_DATA_TOKEN, FooComponent } from './foo.component';
55

66
describe('FooComponent', () => {
77
let fixture: ComponentFixture<FooComponent>;
@@ -13,6 +13,13 @@ describe('FooComponent', () => {
1313
provide: REQUEST,
1414
useValue: {},
1515
},
16+
{
17+
provide: FOO_COMPONENT_DATA_TOKEN,
18+
useValue: {
19+
title: '',
20+
error: new Map(),
21+
},
22+
},
1623
],
1724
}).createComponent(FooComponent);
1825
fixture.detectChanges();
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1-
import { Component, inject } from '@angular/core';
1+
import { Component, Inject, inject, InjectionToken } from '@angular/core';
22
import { Services } from '@shared/shared';
33

4+
export interface ServerError {
5+
title: string;
6+
errors: Map<string, string[]>;
7+
}
8+
9+
export const FOO_COMPONENT_DATA_TOKEN = new InjectionToken<ServerError>('FooComponentData');
10+
411
@Component({
512
template: ` <h1>Foo</h1> `,
613
standalone: true,
714
})
815
export class FooComponent {
916
private readonly appService = inject(Services.AppService);
17+
18+
constructor(@Inject(FOO_COMPONENT_DATA_TOKEN) public data: ServerError) {}
1019
}

examples/example-app-yarn-workspace/packages/angular-app/src/app/shared/foo.component.spec.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ComponentFixture, TestBed } from '@angular/core/testing';
22
import { REQUEST } from '@shared/app.tokens';
33

4-
import { FooComponent } from './foo.component';
4+
import { FOO_COMPONENT_DATA_TOKEN, FooComponent } from './foo.component';
55

66
describe('FooComponent', () => {
77
let fixture: ComponentFixture<FooComponent>;
@@ -13,6 +13,13 @@ describe('FooComponent', () => {
1313
provide: REQUEST,
1414
useValue: {},
1515
},
16+
{
17+
provide: FOO_COMPONENT_DATA_TOKEN,
18+
useValue: {
19+
title: '',
20+
error: new Map(),
21+
},
22+
},
1623
],
1724
}).createComponent(FooComponent);
1825
fixture.detectChanges();

0 commit comments

Comments
 (0)