Browse Source

test(identity): add missing test for state service

pull/2431/head
TheDiaval 7 years ago
parent
commit
ce6b7e2480
  1. 19
      npm/ng-packs/packages/identity/src/lib/tests/identity-state.service.spec.ts

19
npm/ng-packs/packages/identity/src/lib/tests/identity-state.service.spec.ts

@ -2,6 +2,8 @@ import { createServiceFactory, SpectatorService, SpyObject } from '@ngneat/spect
import { IdentityStateService } from '../services/identity-state.service';
import { IdentityState } from '../states/identity.state';
import { Store } from '@ngxs/store';
import * as IdentityActions from '../actions/identity.actions';
describe('IdentityStateService', () => {
let service: IdentityStateService;
let spectator: SpectatorService<IdentityStateService>;
@ -36,4 +38,21 @@ describe('IdentityStateService', () => {
}
});
});
test('should have a dispatch method for every IdentityState action', () => {
const reg = /(?<=dispatch)(\w+)(?=\()/gm;
IdentityStateService.toString()
.match(reg)
.forEach(fnName => {
expect(IdentityActions[fnName]).toBeTruthy();
const spy = jest.spyOn(store, 'dispatch');
spy.mockClear();
const params = Array.from(new Array(IdentityActions[fnName].length));
service[`dispatch${fnName}`](...params);
expect(spy).toHaveBeenCalledWith(new IdentityActions[fnName](...params));
});
});
});

Loading…
Cancel
Save