diff --git a/e2e/ast-transformers/ng-jit-transformers/__tests__/bar.component.spec.ts b/e2e/ast-transformers/ng-jit-transformers/__tests__/bar.component.spec.ts index 43eca39395..74cfe919c1 100644 --- a/e2e/ast-transformers/ng-jit-transformers/__tests__/bar.component.spec.ts +++ b/e2e/ast-transformers/ng-jit-transformers/__tests__/bar.component.spec.ts @@ -1,6 +1,13 @@ -import { Component } from '@angular/core'; +import { Component, Inject, InjectionToken } from '@angular/core'; import { TestBed, waitForAsync } from '@angular/core/testing'; +interface ServerError { + title: string; + errors: Map; +} + +const DATA_TOKEN = new InjectionToken('DataToken'); + @Component({ selector: 'bar', templateUrl: './bar.component.html', @@ -14,11 +21,19 @@ import { TestBed, waitForAsync } from '@angular/core/testing'; `, ], }) -class BarComponent {} +class BarComponent { + constructor(@Inject(DATA_TOKEN) public data: ServerError) {} +} test('templateUrl/styleUrls/styles should work', waitForAsync(() => { TestBed.configureTestingModule({ declarations: [BarComponent], + providers: [ + { + provide: DATA_TOKEN, + useValue: {}, + }, + ], }); const fixture = TestBed.createComponent(BarComponent); fixture.detectChanges(); diff --git a/examples/example-app-monorepo/apps/app1/src/app/shared/foo.component.spec.ts b/examples/example-app-monorepo/apps/app1/src/app/shared/foo.component.spec.ts index fa9f0a0ece..9320c53935 100644 --- a/examples/example-app-monorepo/apps/app1/src/app/shared/foo.component.spec.ts +++ b/examples/example-app-monorepo/apps/app1/src/app/shared/foo.component.spec.ts @@ -1,7 +1,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { REQUEST } from '@shared/app.tokens'; -import { FooComponent } from './foo.component'; +import { FOO_COMPONENT_DATA_TOKEN, FooComponent } from './foo.component'; describe('FooComponent', () => { let fixture: ComponentFixture; @@ -13,6 +13,13 @@ describe('FooComponent', () => { provide: REQUEST, useValue: {}, }, + { + provide: FOO_COMPONENT_DATA_TOKEN, + useValue: { + title: '', + error: new Map(), + }, + }, ], }).createComponent(FooComponent); fixture.detectChanges(); diff --git a/examples/example-app-monorepo/apps/app1/src/app/shared/foo.component.ts b/examples/example-app-monorepo/apps/app1/src/app/shared/foo.component.ts index c865852997..b7bb875cee 100644 --- a/examples/example-app-monorepo/apps/app1/src/app/shared/foo.component.ts +++ b/examples/example-app-monorepo/apps/app1/src/app/shared/foo.component.ts @@ -1,10 +1,19 @@ -import { Component, inject } from '@angular/core'; +import { Component, Inject, inject, InjectionToken } from '@angular/core'; import { Services } from '@shared/shared'; +export interface ServerError { + title: string; + errors: Map; +} + +export const FOO_COMPONENT_DATA_TOKEN = new InjectionToken('FooComponentData'); + @Component({ template: `

Foo

`, standalone: true, }) export class FooComponent { private readonly appService = inject(Services.AppService); + + constructor(@Inject(FOO_COMPONENT_DATA_TOKEN) public data: ServerError) {} } diff --git a/examples/example-app-v15/src/app/shared/foo.component.spec.ts b/examples/example-app-v15/src/app/shared/foo.component.spec.ts index fa9f0a0ece..9320c53935 100644 --- a/examples/example-app-v15/src/app/shared/foo.component.spec.ts +++ b/examples/example-app-v15/src/app/shared/foo.component.spec.ts @@ -1,7 +1,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { REQUEST } from '@shared/app.tokens'; -import { FooComponent } from './foo.component'; +import { FOO_COMPONENT_DATA_TOKEN, FooComponent } from './foo.component'; describe('FooComponent', () => { let fixture: ComponentFixture; @@ -13,6 +13,13 @@ describe('FooComponent', () => { provide: REQUEST, useValue: {}, }, + { + provide: FOO_COMPONENT_DATA_TOKEN, + useValue: { + title: '', + error: new Map(), + }, + }, ], }).createComponent(FooComponent); fixture.detectChanges(); diff --git a/examples/example-app-v15/src/app/shared/foo.component.ts b/examples/example-app-v15/src/app/shared/foo.component.ts index c865852997..b7bb875cee 100644 --- a/examples/example-app-v15/src/app/shared/foo.component.ts +++ b/examples/example-app-v15/src/app/shared/foo.component.ts @@ -1,10 +1,19 @@ -import { Component, inject } from '@angular/core'; +import { Component, Inject, inject, InjectionToken } from '@angular/core'; import { Services } from '@shared/shared'; +export interface ServerError { + title: string; + errors: Map; +} + +export const FOO_COMPONENT_DATA_TOKEN = new InjectionToken('FooComponentData'); + @Component({ template: `

Foo

`, standalone: true, }) export class FooComponent { private readonly appService = inject(Services.AppService); + + constructor(@Inject(FOO_COMPONENT_DATA_TOKEN) public data: ServerError) {} } diff --git a/examples/example-app-v17/src/app/shared/foo.component.spec.ts b/examples/example-app-v17/src/app/shared/foo.component.spec.ts index fa9f0a0ece..9320c53935 100644 --- a/examples/example-app-v17/src/app/shared/foo.component.spec.ts +++ b/examples/example-app-v17/src/app/shared/foo.component.spec.ts @@ -1,7 +1,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { REQUEST } from '@shared/app.tokens'; -import { FooComponent } from './foo.component'; +import { FOO_COMPONENT_DATA_TOKEN, FooComponent } from './foo.component'; describe('FooComponent', () => { let fixture: ComponentFixture; @@ -13,6 +13,13 @@ describe('FooComponent', () => { provide: REQUEST, useValue: {}, }, + { + provide: FOO_COMPONENT_DATA_TOKEN, + useValue: { + title: '', + error: new Map(), + }, + }, ], }).createComponent(FooComponent); fixture.detectChanges(); diff --git a/examples/example-app-v17/src/app/shared/foo.component.ts b/examples/example-app-v17/src/app/shared/foo.component.ts index c865852997..b7bb875cee 100644 --- a/examples/example-app-v17/src/app/shared/foo.component.ts +++ b/examples/example-app-v17/src/app/shared/foo.component.ts @@ -1,10 +1,19 @@ -import { Component, inject } from '@angular/core'; +import { Component, Inject, inject, InjectionToken } from '@angular/core'; import { Services } from '@shared/shared'; +export interface ServerError { + title: string; + errors: Map; +} + +export const FOO_COMPONENT_DATA_TOKEN = new InjectionToken('FooComponentData'); + @Component({ template: `

Foo

`, standalone: true, }) export class FooComponent { private readonly appService = inject(Services.AppService); + + constructor(@Inject(FOO_COMPONENT_DATA_TOKEN) public data: ServerError) {} } diff --git a/examples/example-app-v18/src/app/shared/foo.component.spec.ts b/examples/example-app-v18/src/app/shared/foo.component.spec.ts index fa9f0a0ece..9320c53935 100644 --- a/examples/example-app-v18/src/app/shared/foo.component.spec.ts +++ b/examples/example-app-v18/src/app/shared/foo.component.spec.ts @@ -1,7 +1,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { REQUEST } from '@shared/app.tokens'; -import { FooComponent } from './foo.component'; +import { FOO_COMPONENT_DATA_TOKEN, FooComponent } from './foo.component'; describe('FooComponent', () => { let fixture: ComponentFixture; @@ -13,6 +13,13 @@ describe('FooComponent', () => { provide: REQUEST, useValue: {}, }, + { + provide: FOO_COMPONENT_DATA_TOKEN, + useValue: { + title: '', + error: new Map(), + }, + }, ], }).createComponent(FooComponent); fixture.detectChanges(); diff --git a/examples/example-app-v18/src/app/shared/foo.component.ts b/examples/example-app-v18/src/app/shared/foo.component.ts index c865852997..b7bb875cee 100644 --- a/examples/example-app-v18/src/app/shared/foo.component.ts +++ b/examples/example-app-v18/src/app/shared/foo.component.ts @@ -1,10 +1,19 @@ -import { Component, inject } from '@angular/core'; +import { Component, Inject, inject, InjectionToken } from '@angular/core'; import { Services } from '@shared/shared'; +export interface ServerError { + title: string; + errors: Map; +} + +export const FOO_COMPONENT_DATA_TOKEN = new InjectionToken('FooComponentData'); + @Component({ template: `

Foo

`, standalone: true, }) export class FooComponent { private readonly appService = inject(Services.AppService); + + constructor(@Inject(FOO_COMPONENT_DATA_TOKEN) public data: ServerError) {} } diff --git a/examples/example-app-yarn-workspace/packages/angular-app/src/app/shared/foo.component.spec.ts b/examples/example-app-yarn-workspace/packages/angular-app/src/app/shared/foo.component.spec.ts index fa9f0a0ece..9320c53935 100644 --- a/examples/example-app-yarn-workspace/packages/angular-app/src/app/shared/foo.component.spec.ts +++ b/examples/example-app-yarn-workspace/packages/angular-app/src/app/shared/foo.component.spec.ts @@ -1,7 +1,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { REQUEST } from '@shared/app.tokens'; -import { FooComponent } from './foo.component'; +import { FOO_COMPONENT_DATA_TOKEN, FooComponent } from './foo.component'; describe('FooComponent', () => { let fixture: ComponentFixture; @@ -13,6 +13,13 @@ describe('FooComponent', () => { provide: REQUEST, useValue: {}, }, + { + provide: FOO_COMPONENT_DATA_TOKEN, + useValue: { + title: '', + error: new Map(), + }, + }, ], }).createComponent(FooComponent); fixture.detectChanges(); diff --git a/examples/example-app-yarn-workspace/packages/angular-app/src/app/shared/foo.component.ts b/examples/example-app-yarn-workspace/packages/angular-app/src/app/shared/foo.component.ts index c865852997..b7bb875cee 100644 --- a/examples/example-app-yarn-workspace/packages/angular-app/src/app/shared/foo.component.ts +++ b/examples/example-app-yarn-workspace/packages/angular-app/src/app/shared/foo.component.ts @@ -1,10 +1,19 @@ -import { Component, inject } from '@angular/core'; +import { Component, Inject, inject, InjectionToken } from '@angular/core'; import { Services } from '@shared/shared'; +export interface ServerError { + title: string; + errors: Map; +} + +export const FOO_COMPONENT_DATA_TOKEN = new InjectionToken('FooComponentData'); + @Component({ template: `

Foo

`, standalone: true, }) export class FooComponent { private readonly appService = inject(Services.AppService); + + constructor(@Inject(FOO_COMPONENT_DATA_TOKEN) public data: ServerError) {} }