soapbox/src/actions/rules.test.ts

24 wiersze
717 B
TypeScript
Czysty Zwykły widok Historia

import { __stub } from 'soapbox/api';
import { mockStore, rootState } from 'soapbox/jest/test-helpers';
import { fetchRules, RULES_FETCH_REQUEST, RULES_FETCH_SUCCESS } from './rules';
describe('fetchRules()', () => {
2023-09-20 23:50:17 +00:00
it('sets the rules', async () => {
2023-10-09 03:18:34 +00:00
const rules = await import('soapbox/__fixtures__/rules.json');
__stub((mock) => {
mock.onGet('/api/v1/instance/rules').reply(200, rules);
});
const store = mockStore(rootState);
2023-09-20 23:50:17 +00:00
await store.dispatch(fetchRules());
2023-09-20 23:50:17 +00:00
const actions = store.getActions();
2023-09-20 23:50:17 +00:00
expect(actions[0].type).toEqual(RULES_FETCH_REQUEST);
expect(actions[1].type).toEqual(RULES_FETCH_SUCCESS);
expect(actions[1].payload[0].id).toEqual('1');
});
});