Commit f35d1ccc authored by Thomas Randolph's avatar Thomas Randolph

Update with review notes about unit tests

parent ce92275f
...@@ -28,10 +28,10 @@ describe('MR Notes Mutator Actions', () => { ...@@ -28,10 +28,10 @@ describe('MR Notes Mutator Actions', () => {
}); });
describe('setMrMetadata', () => { describe('setMrMetadata', () => {
it('should trigger the SET_MR_METADATA state mutation', (done) => { it('should trigger the SET_MR_METADATA state mutation', async () => {
const mrMetadata = { propA: 'a', propB: 'b' }; const mrMetadata = { propA: 'a', propB: 'b' };
testAction( await testAction(
setMrMetadata, setMrMetadata,
mrMetadata, mrMetadata,
{}, {},
...@@ -42,7 +42,6 @@ describe('MR Notes Mutator Actions', () => { ...@@ -42,7 +42,6 @@ describe('MR Notes Mutator Actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
...@@ -54,25 +53,25 @@ describe('MR Notes Mutator Actions', () => { ...@@ -54,25 +53,25 @@ describe('MR Notes Mutator Actions', () => {
metadata: 'metadata', metadata: 'metadata',
}, },
}; };
let getSpy;
let mock; let mock;
beforeEach(() => { beforeEach(() => {
getSpy = jest.spyOn(axios, 'get');
mock = new MockAdapter(axios); mock = new MockAdapter(axios);
mock.onGet(state.endpoints.metadata).reply(200, mrMetadata); mock.onGet(state.endpoints.metadata).reply(200, mrMetadata);
}); });
afterEach(() => { afterEach(() => {
getSpy.mockRestore();
mock.restore(); mock.restore();
}); });
it('should fetch the data from the API', async () => { it('should fetch the data from the API', async () => {
await fetchMrMetadata({ state, dispatch: () => {} }); await fetchMrMetadata({ state, dispatch: () => {} });
expect(axios.get).toHaveBeenCalledWith(state.endpoints.metadata); await axios.waitForAll();
expect(mock.history.get).toHaveLength(1);
expect(mock.history.get[0].url).toBe(state.endpoints.metadata);
}); });
it('should set the fetched data into state', () => { it('should set the fetched data into state', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment