test(theme-basic): add missing test for state service

pull/2431/head
TheDiaval 6 years ago
parent f89bade3a6
commit 4b115fb90d

@ -1,7 +1,8 @@
import { createServiceFactory, SpectatorService, SpyObject } from '@ngneat/spectator/jest';
import { Store } from '@ngxs/store';
import * as LayoutActions from '../actions';
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>;
@ -36,4 +37,21 @@ describe('LayoutStateService', () => {
}
});
});
test('should have a dispatch method for every LayoutState action', () => {
const reg = /(?<=dispatch)(\w+)(?=\()/gm;
LayoutStateService.toString()
.match(reg)
.forEach(fnName => {
expect(LayoutActions[fnName]).toBeTruthy();
const spy = jest.spyOn(store, 'dispatch');
spy.mockClear();
const params = Array.from(new Array(LayoutActions[fnName].length));
service[`dispatch${fnName}`](...params);
expect(spy).toHaveBeenCalledWith(new LayoutActions[fnName](...params));
});
});
});

Loading…
Cancel
Save