2022-05-02 12:56:15 +00:00
|
|
|
import { __stub } from 'soapbox/api';
|
|
|
|
import { mockStore, rootState } from 'soapbox/jest/test-helpers';
|
|
|
|
|
2023-10-02 19:27:40 +00:00
|
|
|
import { fetchRules, RULES_FETCH_REQUEST, RULES_FETCH_SUCCESS } from './rules';
|
2022-05-02 12:56:15 +00:00
|
|
|
|
|
|
|
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');
|
2022-05-02 12:56:15 +00:00
|
|
|
|
|
|
|
__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());
|
2022-05-02 12:56:15 +00:00
|
|
|
|
2023-09-20 23:50:17 +00:00
|
|
|
const actions = store.getActions();
|
2022-05-02 12:56:15 +00:00
|
|
|
|
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');
|
2022-05-02 12:56:15 +00:00
|
|
|
});
|
|
|
|
});
|