mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 08:05:43 -06:00
* Add and configure eslint-plugin-import * Fix the lint:ts npm command * Autofix + prettier all the files * Manually fix remaining files * Move jquery code in jest-setup to external file to safely reorder imports * Resolve issue caused by circular dependencies within Prometheus * Update .betterer.results * Fix missing // @ts-ignore * ignore iconBundle.ts * Fix missing // @ts-ignore
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
import { keyBy } from 'lodash';
|
|
|
|
import { getMockInvitees } from 'app/features/users/__mocks__/userMocks';
|
|
|
|
import { reducerTester } from '../../../../test/core/redux/reducerTester';
|
|
|
|
import { fetchInvitees, revokeInvite } from './actions';
|
|
import { initialState, invitesReducer } from './reducers';
|
|
|
|
describe('inviteesReducer', () => {
|
|
describe('when fetchInvitees is dispatched', () => {
|
|
it('then state should be correct', () => {
|
|
const invitees = getMockInvitees(1);
|
|
reducerTester<typeof initialState>()
|
|
.givenReducer(invitesReducer, { ...initialState })
|
|
.whenActionIsDispatched(fetchInvitees.fulfilled(invitees, ''))
|
|
.thenStateShouldEqual({
|
|
entities: keyBy(invitees, 'code'),
|
|
ids: invitees.map((i) => i.code),
|
|
status: 'succeeded',
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('when revokeInvite is dispatched', () => {
|
|
it('then state should be correct', () => {
|
|
const invitees = getMockInvitees(1);
|
|
|
|
const fakeInitialState: typeof initialState = {
|
|
entities: keyBy(invitees, 'code'),
|
|
ids: invitees.map((i) => i.code),
|
|
status: 'succeeded',
|
|
};
|
|
|
|
reducerTester<typeof initialState>()
|
|
.givenReducer(invitesReducer, fakeInitialState)
|
|
.whenActionIsDispatched(revokeInvite.fulfilled(invitees[0].code, '', ''))
|
|
.thenStateShouldEqual({
|
|
entities: {
|
|
[invitees[1].code]: invitees[1],
|
|
},
|
|
ids: [invitees[1].code],
|
|
status: 'succeeded',
|
|
});
|
|
});
|
|
});
|
|
});
|