Commit 03a8ca47 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch 'remove-return-promise-from-mr-widget-spec' into 'master'

Simplify mocked promises

See merge request gitlab-org/gitlab!51966
parents 39da9514 042ad267
...@@ -17,13 +17,6 @@ jest.mock('~/smart_interval'); ...@@ -17,13 +17,6 @@ jest.mock('~/smart_interval');
jest.mock('~/lib/utils/favicon'); jest.mock('~/lib/utils/favicon');
const returnPromise = (data) =>
new Promise((resolve) => {
resolve({
data,
});
});
describe('MrWidgetOptions', () => { describe('MrWidgetOptions', () => {
let wrapper; let wrapper;
let mock; let mock;
...@@ -281,7 +274,7 @@ describe('MrWidgetOptions', () => { ...@@ -281,7 +274,7 @@ describe('MrWidgetOptions', () => {
let isCbExecuted; let isCbExecuted;
beforeEach(() => { beforeEach(() => {
jest.spyOn(wrapper.vm.service, 'checkStatus').mockReturnValue(returnPromise(mockData)); jest.spyOn(wrapper.vm.service, 'checkStatus').mockResolvedValue({ data: mockData });
jest.spyOn(wrapper.vm.mr, 'setData').mockImplementation(() => {}); jest.spyOn(wrapper.vm.mr, 'setData').mockImplementation(() => {});
jest.spyOn(wrapper.vm, 'handleNotification').mockImplementation(() => {}); jest.spyOn(wrapper.vm, 'handleNotification').mockImplementation(() => {});
...@@ -331,7 +324,7 @@ describe('MrWidgetOptions', () => { ...@@ -331,7 +324,7 @@ describe('MrWidgetOptions', () => {
it('should fetch deployments', () => { it('should fetch deployments', () => {
jest jest
.spyOn(wrapper.vm.service, 'fetchDeployments') .spyOn(wrapper.vm.service, 'fetchDeployments')
.mockReturnValue(returnPromise([{ id: 1, status: SUCCESS }])); .mockResolvedValue({ data: [{ id: 1, status: SUCCESS }] });
wrapper.vm.fetchPreMergeDeployments(); wrapper.vm.fetchPreMergeDeployments();
...@@ -347,7 +340,7 @@ describe('MrWidgetOptions', () => { ...@@ -347,7 +340,7 @@ describe('MrWidgetOptions', () => {
it('should fetch content of Cherry Pick and Revert modals', () => { it('should fetch content of Cherry Pick and Revert modals', () => {
jest jest
.spyOn(wrapper.vm.service, 'fetchMergeActionsContent') .spyOn(wrapper.vm.service, 'fetchMergeActionsContent')
.mockReturnValue(returnPromise('hello world')); .mockResolvedValue({ data: 'hello world' });
wrapper.vm.fetchActionsContent(); wrapper.vm.fetchActionsContent();
......
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