reducers.test.ts 814 B

123456789101112131415161718192021222324
  1. import { Action, ActionTypes } from './actions';
  2. import { OrgRole, PermissionLevel, DashboardState } from 'app/types';
  3. import { initialState, dashboardReducer } from './reducers';
  4. describe('dashboard reducer', () => {
  5. describe('loadDashboardPermissions', () => {
  6. let state: DashboardState;
  7. beforeEach(() => {
  8. const action: Action = {
  9. type: ActionTypes.LoadDashboardPermissions,
  10. payload: [
  11. { id: 2, dashboardId: 1, role: OrgRole.Viewer, permission: PermissionLevel.View },
  12. { id: 3, dashboardId: 1, role: OrgRole.Editor, permission: PermissionLevel.Edit },
  13. ],
  14. };
  15. state = dashboardReducer(initialState, action);
  16. });
  17. it('should add permissions to state', async () => {
  18. expect(state.permissions.length).toBe(2);
  19. });
  20. });
  21. });