Add test for 'patchMe' action

rtk-query
Justin 2022-07-18 12:53:57 -04:00
rodzic 781639bde8
commit d807aae502
1 zmienionych plików z 31 dodań i 1 usunięć

Wyświetl plik

@ -4,7 +4,7 @@ import { __stub } from 'soapbox/api';
import { mockStore, rootState } from 'soapbox/jest/test-helpers';
import {
fetchMe,
fetchMe, patchMe,
} from '../me';
jest.mock('../../storage/kv_store', () => ({
@ -82,4 +82,34 @@ describe('fetchMe()', () => {
});
});
});
});
describe('patchMe()', () => {
beforeEach(() => {
const state = rootState;
store = mockStore(state);
});
describe('with a successful API response', () => {
beforeEach(() => {
__stub((mock) => {
mock.onPatch('/api/v1/accounts/update_credentials').reply(200, {});
});
});
it('dispatches the correct actions', async() => {
const expectedActions = [
{ type: 'ME_PATCH_REQUEST' },
{ type: 'ACCOUNTS_IMPORT', accounts: [] },
{
type: 'ME_PATCH_SUCCESS',
me: {},
},
];
await store.dispatch(patchMe({}));
const actions = store.getActions();
expect(actions).toEqual(expectedActions);
});
});
});