Skip to content
代码片段 群组 项目
未验证 提交 f35d1ccc 编辑于 作者: Thomas Randolph's avatar Thomas Randolph
浏览文件

Update with review notes about unit tests

上级 ce92275f
No related branches found
No related tags found
无相关合并请求
......@@ -28,10 +28,10 @@ describe('MR Notes Mutator Actions', () => {
});
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' };
testAction(
await testAction(
setMrMetadata,
mrMetadata,
{},
......@@ -42,7 +42,6 @@ describe('MR Notes Mutator Actions', () => {
},
],
[],
done,
);
});
});
......@@ -54,25 +53,25 @@ describe('MR Notes Mutator Actions', () => {
metadata: 'metadata',
},
};
let getSpy;
let mock;
beforeEach(() => {
getSpy = jest.spyOn(axios, 'get');
mock = new MockAdapter(axios);
mock.onGet(state.endpoints.metadata).reply(200, mrMetadata);
});
afterEach(() => {
getSpy.mockRestore();
mock.restore();
});
it('should fetch the data from the API', async () => {
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', () => {
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册