diff --git a/npm/ng-packs/packages/theme-basic/src/lib/tests/layout-state.service.spec.ts b/npm/ng-packs/packages/theme-basic/src/lib/tests/layout-state.service.spec.ts index 2a88a93f47..de4f489aaa 100644 --- a/npm/ng-packs/packages/theme-basic/src/lib/tests/layout-state.service.spec.ts +++ b/npm/ng-packs/packages/theme-basic/src/lib/tests/layout-state.service.spec.ts @@ -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; @@ -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)); + }); + }); });