Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion modules/store/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export default [
{
ignores: [
'**/dist',
'**/jest.config.ts',
'**/schematics-core/**/*.ts',
],
},
Expand Down
30 changes: 0 additions & 30 deletions modules/store/jest.config.ts

This file was deleted.

5 changes: 4 additions & 1 deletion modules/store/migrations/13_0_0-beta/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import {
import * as path from 'path';

describe('Store Migration 13_0_0 beta', () => {
const collectionPath = path.join(__dirname, '../migration.json');
const collectionPath = path.join(
process.cwd(),
'dist/modules/store/migrations/migration.json'
);
const pkgName = 'store';

it(`should replace createFeatureSelector usages with 2 generics`, async () => {
Expand Down
5 changes: 4 additions & 1 deletion modules/store/migrations/13_0_0-rc/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import {
import * as path from 'path';

describe('Store Migration 13_0_1', () => {
const collectionPath = path.join(__dirname, '../migration.json');
const collectionPath = path.join(
process.cwd(),
'dist/modules/store/migrations/migration.json'
);
const pkgName = 'store';

it(`should replace createSelector with explicit generics usages with explicit generics using Slices tuple`, async () => {
Expand Down
5 changes: 4 additions & 1 deletion modules/store/migrations/15_2_0/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import {
import * as path from 'path';

describe('Store Migration 15_2_0', () => {
const collectionPath = path.join(__dirname, '../migration.json');
const collectionPath = path.join(
process.cwd(),
'dist/modules/store/migrations/migration.json'
);
const pkgName = 'store';

it(`should replace remove the State type argument`, async () => {
Expand Down
9 changes: 6 additions & 3 deletions modules/store/migrations/16_0_0-beta/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@ import {
import * as path from 'path';

describe('Store Migration 16_0_0-beta', () => {
const collectionPath = path.join(__dirname, '../migration.json');
const collectionPath = path.join(
process.cwd(),
'dist/modules/store/migrations/migration.json'
);

it(`should replace getMockStore with createMockStore`, async () => {
const input = `
import { getMockStore } from '@ngrx/store';
import { SomethingElse } from '@ngrx/store';
import {getMockStore} from '@ngrx/store';
import {foo, getMockStore, bar} from '@ngrx/store';

const mockStore = getMockStore();

it('just a test', () => {
Expand All @@ -27,7 +30,7 @@ describe('Store Migration 16_0_0-beta', () => {
import { SomethingElse } from '@ngrx/store';
import {createMockStore} from '@ngrx/store';
import {foo,createMockStore, bar} from '@ngrx/store';

const mockStore =createMockStore();

it('just a test', () => {
Expand Down
5 changes: 4 additions & 1 deletion modules/store/migrations/18_0_0-beta/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import * as path from 'path';
import { tags } from '@angular-devkit/core';

describe('Store Migration to 18.0.0-beta', () => {
const collectionPath = path.join(__dirname, '../migration.json');
const collectionPath = path.join(
process.cwd(),
'dist/modules/store/migrations/migration.json'
);
const schematicRunner = new SchematicTestRunner('schematics', collectionPath);

let appTree: UnitTestTree;
Expand Down
5 changes: 4 additions & 1 deletion modules/store/migrations/6_0_0/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import {
versionPrefixes,
} from '@ngrx/schematics-core/testing/update';

const collectionPath = path.join(__dirname, '../migration.json');
const collectionPath = path.join(
process.cwd(),
'dist/modules/store/migrations/migration.json'
);

describe('Store Migration 6_0_0', () => {
let appTree;
Expand Down
5 changes: 4 additions & 1 deletion modules/store/migrations/8_0_0-beta/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import { createPackageJson } from '@ngrx/schematics-core/testing/create-package'

describe('Store Migration 8_0_0 beta', () => {
let appTree: UnitTestTree;
const collectionPath = path.join(__dirname, '../migration.json');
const collectionPath = path.join(
process.cwd(),
'dist/modules/store/migrations/migration.json'
);
const pkgName = 'store';
beforeEach(() => {
appTree = new UnitTestTree(Tree.empty());
Expand Down
3 changes: 2 additions & 1 deletion modules/store/migrations/8_0_0-rc/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as path from 'node:path';
import { normalize } from '@angular-devkit/core';
import { EmptyTree } from '@angular-devkit/schematics';
import {
Expand Down Expand Up @@ -262,7 +263,7 @@ describe('Migration to version 8.0.0 rc', () => {
function createSchematicsRunner() {
const schematicRunner = new SchematicTestRunner(
'migrations',
require.resolve('../migration.json')
path.join(process.cwd(), 'dist/modules/store/migrations/migration.json')
);

return schematicRunner;
Expand Down
8 changes: 2 additions & 6 deletions modules/store/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,8 @@
"outputs": ["{options.outputFile}"]
},
"test": {
"executor": "@nx/jest:jest",
"options": {
"jestConfig": "modules/store/jest.config.ts",
"runInBand": true,
"passWithNoTests": false
},
"executor": "@analogjs/vitest-angular:test",
"dependsOn": ["build"],
"outputs": ["{workspaceRoot}/coverage/modules/store"]
}
}
Expand Down
2 changes: 1 addition & 1 deletion modules/store/schematics/ng-add/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
describe('Store ng-add Schematic', () => {
const schematicRunner = new SchematicTestRunner(
'@ngrx/store',
path.join(__dirname, '../collection.json')
path.join(process.cwd(), 'dist/modules/store/schematics/collection.json')
);
const defaultOptions: RootStoreOptions = {
skipPackageJson: false,
Expand Down
11 changes: 0 additions & 11 deletions modules/store/spec/action_creator.spec.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
import { createAction, props, union } from '..';

describe('Action Creators', () => {
let originalTimeout: number;

beforeEach(() => {
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 2000;
});

afterEach(() => {
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
});

describe('createAction', () => {
it('should create an action', () => {
const foo = createAction('FOO', (foo: number) => ({ foo }));
Expand Down
37 changes: 19 additions & 18 deletions modules/store/spec/edge.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,29 @@ describe('ngRx Store', () => {
expect(store).toBeDefined();
});

it('should handle re-entrancy', (done: any) => {
let todosNextCount = 0;
let todosCountNextCount = 0;
it('should handle re-entrancy', () =>
new Promise<void>((done) => {
let todosNextCount = 0;
let todosCountNextCount = 0;

store.pipe(select('todos')).subscribe((todos) => {
todosNextCount++;
store.dispatch({ type: 'SET_COUNT', payload: todos.length });
});

store.pipe(select('todoCount')).subscribe((count) => {
todosCountNextCount++;
});
store.pipe(select('todos')).subscribe((todos) => {
todosNextCount++;
store.dispatch({ type: 'SET_COUNT', payload: todos.length });
});

store.dispatch({ type: 'ADD_TODO', payload: { name: 'test' } });
expect(todosNextCount).toBe(2);
expect(todosCountNextCount).toBe(2);
store.pipe(select('todoCount')).subscribe((count) => {
todosCountNextCount++;
});

setTimeout(() => {
store.dispatch({ type: 'ADD_TODO', payload: { name: 'test' } });
expect(todosNextCount).toBe(2);
expect(todosCountNextCount).toBe(2);
done();
}, 10);
});

setTimeout(() => {
expect(todosNextCount).toBe(2);
expect(todosCountNextCount).toBe(2);
done();
}, 10);
}));
});
});
35 changes: 18 additions & 17 deletions modules/store/spec/feature_creator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,23 +212,24 @@ describe('createFeature()', () => {
});
});

it('should set up a feature state', (done) => {
const initialFooState = { x: 1, y: 2, z: 3 };
const fooFeature = createFeature({
name: 'foo',
reducer: createReducer(initialFooState),
});

TestBed.configureTestingModule({
imports: [StoreModule.forRoot({}), StoreModule.forFeature(fooFeature)],
});
it('should set up a feature state', () =>
new Promise<void>((done) => {
const initialFooState = { x: 1, y: 2, z: 3 };
const fooFeature = createFeature({
name: 'foo',
reducer: createReducer(initialFooState),
});

TestBed.inject(Store)
.select(fooFeature.name)
.pipe(take(1))
.subscribe((fooState) => {
expect(fooState).toEqual(initialFooState);
done();
TestBed.configureTestingModule({
imports: [StoreModule.forRoot({}), StoreModule.forFeature(fooFeature)],
});
});

TestBed.inject(Store)
.select(fooFeature.name)
.pipe(take(1))
.subscribe((fooState) => {
expect(fooState).toEqual(initialFooState);
done();
});
}));
});
Loading
Loading