mirror of https://github.com/abpframework/abp
parent
690b18debf
commit
0d650cfccd
@ -1,21 +1,39 @@
|
||||
import { createServiceFactory, SpectatorService } from '@ngneat/spectator/jest';
|
||||
import { createServiceFactory, SpectatorService, SpyObject } from '@ngneat/spectator/jest';
|
||||
import { IdentityStateService } from '../services/identity-state.service';
|
||||
import { IdentityState } from '../states/identity.state';
|
||||
import { Store } from '@ngxs/store';
|
||||
describe('IdentityStateService', () => {
|
||||
let service: IdentityStateService;
|
||||
let spectator: SpectatorService<IdentityStateService>;
|
||||
let store: SpyObject<Store>;
|
||||
|
||||
const createService = createServiceFactory({ service: IdentityStateService, mocks: [Store] });
|
||||
beforeEach(() => {
|
||||
spectator = createService();
|
||||
service = spectator.service;
|
||||
store = spectator.get(Store);
|
||||
});
|
||||
|
||||
test('should have the all IdentityState static methods', () => {
|
||||
const reg = /(?<=static )(.*)(?=\()/gm;
|
||||
IdentityState.toString()
|
||||
.match(reg)
|
||||
.forEach(fnName => {
|
||||
expect(service[fnName]).toBeTruthy();
|
||||
|
||||
const spy = jest.spyOn(store, 'selectSnapshot');
|
||||
spy.mockClear();
|
||||
|
||||
const isDynamicSelector = IdentityState[fnName].name !== 'memoized';
|
||||
|
||||
if (isDynamicSelector) {
|
||||
IdentityState[fnName] = jest.fn((...args) => args);
|
||||
service[fnName]('test', 0, {});
|
||||
expect(IdentityState[fnName]).toHaveBeenCalledWith('test', 0, {});
|
||||
} else {
|
||||
service[fnName]();
|
||||
expect(spy).toHaveBeenCalledWith(IdentityState[fnName]);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,21 +1,39 @@
|
||||
import { createServiceFactory, SpectatorService } from '@ngneat/spectator/jest';
|
||||
import { createServiceFactory, SpectatorService, SpyObject } from '@ngneat/spectator/jest';
|
||||
import { TenantManagementStateService } from '../services/tenant-management-state.service';
|
||||
import { TenantManagementState } from '../states/tenant-management.state';
|
||||
import { Store } from '@ngxs/store';
|
||||
describe('TenantManagementStateService', () => {
|
||||
let service: TenantManagementStateService;
|
||||
let spectator: SpectatorService<TenantManagementStateService>;
|
||||
let store: SpyObject<Store>;
|
||||
|
||||
const createService = createServiceFactory({ service: TenantManagementStateService, mocks: [Store] });
|
||||
beforeEach(() => {
|
||||
spectator = createService();
|
||||
service = spectator.service;
|
||||
store = spectator.get(Store);
|
||||
});
|
||||
|
||||
test('should have the all TenantManagementState static methods', () => {
|
||||
const reg = /(?<=static )(.*)(?=\()/gm;
|
||||
TenantManagementState.toString()
|
||||
.match(reg)
|
||||
.forEach(fnName => {
|
||||
expect(service[fnName]).toBeTruthy();
|
||||
|
||||
const spy = jest.spyOn(store, 'selectSnapshot');
|
||||
spy.mockClear();
|
||||
|
||||
const isDynamicSelector = TenantManagementState[fnName].name !== 'memoized';
|
||||
|
||||
if (isDynamicSelector) {
|
||||
TenantManagementState[fnName] = jest.fn((...args) => args);
|
||||
service[fnName]('test', 0, {});
|
||||
expect(TenantManagementState[fnName]).toHaveBeenCalledWith('test', 0, {});
|
||||
} else {
|
||||
service[fnName]();
|
||||
expect(spy).toHaveBeenCalledWith(TenantManagementState[fnName]);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,21 +1,39 @@
|
||||
import { createServiceFactory, SpectatorService } from '@ngneat/spectator/jest';
|
||||
import { createServiceFactory, SpectatorService, SpyObject } from '@ngneat/spectator/jest';
|
||||
import { LayoutStateService } from '../services/layout-state.service';
|
||||
import { LayoutState } from '../states/layout.state';
|
||||
import { Store } from '@ngxs/store';
|
||||
describe('LayoutStateService', () => {
|
||||
let service: LayoutStateService;
|
||||
let spectator: SpectatorService<LayoutStateService>;
|
||||
let store: SpyObject<Store>;
|
||||
|
||||
const createService = createServiceFactory({ service: LayoutStateService, mocks: [Store] });
|
||||
beforeEach(() => {
|
||||
spectator = createService();
|
||||
service = spectator.service;
|
||||
store = spectator.get(Store);
|
||||
});
|
||||
|
||||
test('should have the all LayoutState static methods', () => {
|
||||
const reg = /(?<=static )(.*)(?=\()/gm;
|
||||
LayoutState.toString()
|
||||
.match(reg)
|
||||
.forEach(fnName => {
|
||||
expect(service[fnName]).toBeTruthy();
|
||||
|
||||
const spy = jest.spyOn(store, 'selectSnapshot');
|
||||
spy.mockClear();
|
||||
|
||||
const isDynamicSelector = LayoutState[fnName].name !== 'memoized';
|
||||
|
||||
if (isDynamicSelector) {
|
||||
LayoutState[fnName] = jest.fn((...args) => args);
|
||||
service[fnName]('test', 0, {});
|
||||
expect(LayoutState[fnName]).toHaveBeenCalledWith('test', 0, {});
|
||||
} else {
|
||||
service[fnName]();
|
||||
expect(spy).toHaveBeenCalledWith(LayoutState[fnName]);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in new issue