Skip to content

Commit

Permalink
build: update to Angular 19-next
Browse files Browse the repository at this point in the history
  • Loading branch information
timdeschryver committed Oct 28, 2024
1 parent 269bd32 commit b0a47de
Show file tree
Hide file tree
Showing 39 changed files with 2,293 additions and 1,502 deletions.
5 changes: 5 additions & 0 deletions modules/component-store/spec/integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ describe('ComponentStore integration', () => {
@Component({
selector: 'body',
template: '<child *ngIf="isChildVisible"></child>',
standalone: false,
})
class ParentComponent implements Parent {
isChildVisible = true;
Expand Down Expand Up @@ -249,6 +250,7 @@ describe('ComponentStore integration', () => {
selector: 'child',
template: '<div>{{prop$ | async}}</div>',
providers: [ComponentStore],
standalone: false,
})
class ChildComponent implements Child {
prop$ = this.componentStore.select((state) => state.prop);
Expand Down Expand Up @@ -298,6 +300,7 @@ describe('ComponentStore integration', () => {
@Component({
selector: 'child',
template: '<div>{{prop$ | async}}</div>',
standalone: false,
})
class ChildComponent extends ComponentStore<State> implements Child {
prop$ = this.select((state) => state.prop);
Expand Down Expand Up @@ -398,6 +401,7 @@ describe('ComponentStore integration', () => {
selector: 'child',
template: '<div>{{prop$ | async}}</div>',
providers: [PropsStore],
standalone: false,
})
class ChildComponent implements Child {
prop$ = this.propsStore.prop$;
Expand Down Expand Up @@ -464,6 +468,7 @@ describe('ComponentStore integration', () => {
@Component({
selector: 'child',
template: '<div>{{prop$ | async}}</div>',
standalone: false,
})
class ChildComponent extends PropsStore implements Child {
interval$ = interval(10);
Expand Down
37 changes: 15 additions & 22 deletions modules/component/spec/let/let.directive.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
flushMicrotasks,
TestBed,
tick,
waitForAsync,
} from '@angular/core/testing';
import {
BehaviorSubject,
Expand All @@ -27,16 +26,18 @@ import {
throwError,
timer,
} from 'rxjs';
import { LetDirective } from '../../src/let/let.directive';
import { MockChangeDetectorRef, MockErrorHandler } from '../fixtures/fixtures';
import { stripSpaces } from '../helpers';
import { JsonPipe } from '@angular/common';
import { LetDirective } from '../..';

@Component({
template: `
<ng-container *ngrxLet="value$ as value">{{
value === null ? 'null' : (value | json) || 'undefined'
}}</ng-container>
`,
imports: [JsonPipe, LetDirective],
})
class LetDirectiveTestComponent {
value$: unknown;
Expand All @@ -48,6 +49,7 @@ class LetDirectiveTestComponent {
error === undefined ? 'undefined' : error
}}</ng-container>
`,
imports: [LetDirective],
})
class LetDirectiveTestErrorComponent {
value$ = of(42);
Expand All @@ -59,6 +61,7 @@ class LetDirectiveTestErrorComponent {
complete
}}</ng-container>
`,
imports: [LetDirective],
})
class LetDirectiveTestCompleteComponent {
value$ = of(42);
Expand All @@ -68,6 +71,7 @@ class LetDirectiveTestCompleteComponent {
template: `
<ng-container *ngrxLet="value$ as value">{{ value }}</ng-container>
`,
imports: [LetDirective],
})
class LetDirectiveTestSuspenseComponent {
value$ = of(42);
Expand All @@ -80,6 +84,7 @@ class LetDirectiveTestSuspenseComponent {
}}</ng-container>
<ng-template #loading>Loading...</ng-template>
`,
imports: [LetDirective],
})
class LetDirectiveTestSuspenseTplComponent {
value$ = of(42);
Expand All @@ -100,6 +105,7 @@ export class RecursiveDirective {
value
}}</ng-container>
`,
imports: [RecursiveDirective, LetDirective],
})
class LetDirectiveTestRecursionComponent {
constructor(public subject: BehaviorSubject<number>) {}
Expand All @@ -117,8 +123,6 @@ let componentNativeElement: any;

const setupLetDirectiveTestComponent = (): void => {
TestBed.configureTestingModule({
declarations: [LetDirectiveTestComponent],
imports: [LetDirective],
providers: [
{ provide: ChangeDetectorRef, useClass: MockChangeDetectorRef },
TemplateRef,
Expand All @@ -135,8 +139,6 @@ const setupLetDirectiveTestComponent = (): void => {

const setupLetDirectiveTestComponentError = (): void => {
TestBed.configureTestingModule({
declarations: [LetDirectiveTestErrorComponent],
imports: [LetDirective],
providers: [
{ provide: ChangeDetectorRef, useClass: MockChangeDetectorRef },
{ provide: ErrorHandler, useClass: MockErrorHandler },
Expand All @@ -155,8 +157,6 @@ const setupLetDirectiveTestComponentError = (): void => {

const setupLetDirectiveTestComponentComplete = (): void => {
TestBed.configureTestingModule({
declarations: [LetDirectiveTestCompleteComponent],
imports: [LetDirective],
providers: [
{ provide: ChangeDetectorRef, useClass: MockChangeDetectorRef },
TemplateRef,
Expand All @@ -174,8 +174,6 @@ const setupLetDirectiveTestComponentComplete = (): void => {

const setupLetDirectiveTestComponentSuspense = (): void => {
TestBed.configureTestingModule({
declarations: [LetDirectiveTestSuspenseComponent],
imports: [LetDirective],
providers: [
{ provide: ChangeDetectorRef, useClass: MockChangeDetectorRef },
{ provide: ErrorHandler, useClass: MockErrorHandler },
Expand All @@ -194,8 +192,6 @@ const setupLetDirectiveTestComponentSuspense = (): void => {

const setupLetDirectiveTestComponentSuspenseTpl = (): void => {
TestBed.configureTestingModule({
declarations: [LetDirectiveTestSuspenseTplComponent],
imports: [LetDirective],
providers: [
{ provide: ChangeDetectorRef, useClass: MockChangeDetectorRef },
{ provide: ErrorHandler, useClass: MockErrorHandler },
Expand All @@ -215,8 +211,6 @@ const setupLetDirectiveTestComponentSuspenseTpl = (): void => {
const setupLetDirectiveTestRecursionComponent = (): void => {
const subject = new BehaviorSubject(0);
TestBed.configureTestingModule({
declarations: [LetDirectiveTestRecursionComponent, RecursiveDirective],
imports: [LetDirective],
providers: [
{ provide: ChangeDetectorRef, useClass: MockChangeDetectorRef },
TemplateRef,
Expand All @@ -234,7 +228,7 @@ const setupLetDirectiveTestRecursionComponent = (): void => {

describe('LetDirective', () => {
describe('when nexting values', () => {
beforeEach(waitForAsync(setupLetDirectiveTestComponent));
beforeEach(setupLetDirectiveTestComponent);

it('should be instantiable', () => {
expect(fixtureLetDirectiveTestComponent).toBeDefined();
Expand Down Expand Up @@ -402,7 +396,7 @@ describe('LetDirective', () => {
});

describe('when error', () => {
beforeEach(waitForAsync(setupLetDirectiveTestComponentError));
beforeEach(setupLetDirectiveTestComponentError);

it('should render undefined when next event is emitted', () => {
letDirectiveTestComponent.value$ = new BehaviorSubject(1);
Expand Down Expand Up @@ -432,7 +426,7 @@ describe('LetDirective', () => {
});

describe('when complete', () => {
beforeEach(waitForAsync(setupLetDirectiveTestComponentComplete));
beforeEach(setupLetDirectiveTestComponentComplete);

it('should render true if completed', () => {
letDirectiveTestComponent.value$ = EMPTY;
Expand All @@ -442,7 +436,7 @@ describe('LetDirective', () => {
});

describe('when suspense', () => {
beforeEach(waitForAsync(setupLetDirectiveTestComponentSuspense));
beforeEach(setupLetDirectiveTestComponentSuspense);

it('should not render when first observable is in suspense state', fakeAsync(() => {
letDirectiveTestComponent.value$ = of(true).pipe(delay(1000));
Expand All @@ -466,7 +460,7 @@ describe('LetDirective', () => {
});

describe('when suspense template is passed', () => {
beforeEach(waitForAsync(setupLetDirectiveTestComponentSuspenseTpl));
beforeEach(setupLetDirectiveTestComponentSuspenseTpl);

it('should render main template when observable emits next event', () => {
letDirectiveTestComponent.value$ = new BehaviorSubject('ngrx');
Expand Down Expand Up @@ -516,7 +510,7 @@ describe('LetDirective', () => {
});

describe('when rendering recursively', () => {
beforeEach(waitForAsync(setupLetDirectiveTestRecursionComponent));
beforeEach(setupLetDirectiveTestRecursionComponent);

it('should render 2nd emitted value if the observable emits while the view is being rendered', fakeAsync(() => {
fixtureLetDirectiveTestComponent.detectChanges();
Expand All @@ -536,15 +530,14 @@ describe('LetDirective', () => {
vm.o1 + '-' + vm.o2
}}</ng-container>
`,
imports: [LetDirective],
})
class LetDirectiveTestComponent {
o1$ = config.o1$;
o2$ = config.o2$;
}

TestBed.configureTestingModule({
declarations: [LetDirectiveTestComponent],
imports: [LetDirective],
providers: [
{ provide: ChangeDetectorRef, useClass: MockChangeDetectorRef },
{ provide: ErrorHandler, useClass: MockErrorHandler },
Expand Down
4 changes: 2 additions & 2 deletions modules/component/spec/push/push.pipe.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ import {
import { PushPipe } from '../../src/push/push.pipe';
import { MockChangeDetectorRef, MockErrorHandler } from '../fixtures/fixtures';
import { stripSpaces, wrapWithSpace } from '../helpers';
import { JsonPipe } from '@angular/common';

let pushPipe: PushPipe;

@Component({
template: ` {{ (value$ | ngrxPush | json) || 'undefined' }} `,
imports: [PushPipe, JsonPipe],
})
class PushPipeTestComponent {
value$: unknown = of(42);
Expand Down Expand Up @@ -200,8 +202,6 @@ describe('PushPipe', () => {
describe('used as a Pipe', () => {
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [PushPipeTestComponent],
imports: [PushPipe],
providers: [{ provide: ErrorHandler, useClass: MockErrorHandler }],
});

Expand Down
15 changes: 12 additions & 3 deletions modules/data/schematics/ng-add/__snapshots__/index.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import { provideEntityData } from '@ngrx/data';
import { entityConfig } from './entity-metadata';
export const appConfig: ApplicationConfig = {
providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideEntityData(entityConfig)]
providers: [
provideZoneChangeDetection({ eventCoalescing: true }),
provideEntityData(entityConfig)
]
};
"
`;
Expand All @@ -16,7 +19,10 @@ exports[`Data ng-add Schematic Migration of ngrx-data Data ng-add Schematic for
import { provideEntityData, withEffects } from '@ngrx/data';
export const appConfig: ApplicationConfig = {
providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideEntityData({}, withEffects())]
providers: [
provideZoneChangeDetection({ eventCoalescing: true }),
provideEntityData({}, withEffects())
]
};
"
`;
Expand All @@ -27,7 +33,10 @@ import { provideEntityData, withEffects } from '@ngrx/data';
import { entityConfig } from './entity-metadata';
export const appConfig: ApplicationConfig = {
providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideEntityData(entityConfig, withEffects())]
providers: [
provideZoneChangeDetection({ eventCoalescing: true }),
provideEntityData(entityConfig, withEffects())
]
};
"
`;
4 changes: 2 additions & 2 deletions modules/data/schematics/ng-add/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,15 @@ describe('Data ng-add Schematic', () => {

const tree = await schematicRunner.runSchematic('ng-add', options, appTree);
const content = tree.readContent(`${projectPath}/src/app/app.module.ts`);
expect(content).toMatch(/EntityDataModule\n/);
expect(content).toMatch(/EntityDataModule/);
});

it('should register EntityDataModuleWithoutEffects in the provided module', async () => {
const options = { ...defaultOptions, effects: false, entityConfig: false };

const tree = await schematicRunner.runSchematic('ng-add', options, appTree);
const content = tree.readContent(`${projectPath}/src/app/app.module.ts`);
expect(content).toMatch(/EntityDataModuleWithoutEffects\n/);
expect(content).toMatch(/EntityDataModuleWithoutEffects/);
});

describe('Migration of ngrx-data', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import { provideEffects } from '@ngrx/effects';
import { FooEffects } from './foo/foo.effects';
export const appConfig: ApplicationConfig = {
providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideEffects(FooEffects)]
providers: [
provideZoneChangeDetection({ eventCoalescing: true }),
provideEffects(FooEffects)
]
};
"
`;
Expand All @@ -16,7 +19,10 @@ exports[`Effects ng-add Schematic Effects ng-add Schematic for standalone applic
import { provideEffects } from '@ngrx/effects';
export const appConfig: ApplicationConfig = {
providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideEffects()]
providers: [
provideZoneChangeDetection({ eventCoalescing: true }),
provideEffects()
]
};
"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ exports[`Router Store ng-add Schematic Router Store ng-add Schematic for standal
import { provideRouterStore } from '@ngrx/router-store';
export const appConfig: ApplicationConfig = {
providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideRouterStore()]
providers: [
provideZoneChangeDetection({ eventCoalescing: true }),
provideRouterStore()
]
};
"
`;
3 changes: 2 additions & 1 deletion modules/router-store/spec/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { RouterTestingModule } from '@angular/router/testing';
import { StoreModule } from '@ngrx/store';

import { StoreRouterConfig, StoreRouterConnectingModule } from '../src';
import { RouterOutlet } from '@angular/router';

export function createTestModule(
opts: {
Expand All @@ -17,6 +18,7 @@ export function createTestModule(
@Component({
selector: 'test-app',
template: '<router-outlet></router-outlet>',
imports: [RouterOutlet],
})
class AppComponent {}

Expand All @@ -27,7 +29,6 @@ export function createTestModule(
class SimpleComponent {}

TestBed.configureTestingModule({
declarations: [AppComponent, SimpleComponent],
imports: [
StoreModule.forRoot(opts.reducers),
RouterTestingModule.withRoutes([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import { FooStore } from './foo/foo.store';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
standalone: false,
styleUrl: './app.component.css',
providers: [FooStore]
})
Expand Down
Loading

0 comments on commit b0a47de

Please sign in to comment.