Commit 6d92d439 authored by Vitaly Slobodin's avatar Vitaly Slobodin Committed by Natalia Tepluhina

Replace jasmine functions in EE Jest specs

Replace Jasmine globals with Jest equivalents and
disallow further usage of Jasmine global in Jest specs.
parent 1b238d9b
---
extends: ../../../spec/frontend/.eslintrc.yml
rules:
jest/no-jasmine-globals: off
jest/valid-describe: off
......@@ -45,7 +45,7 @@ describe('Api', () => {
it('calls callback on completion', done => {
const query = 'query';
const provider = 'provider';
const callback = jasmine.createSpy();
const callback = jest.fn();
const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/ldap/${provider}/groups.json`;
mock.onGet(expectedUrl).reply(200, [
......
......@@ -50,7 +50,7 @@ describe('Approvals ModalRuleRemove', () => {
data: TEST_RULE,
};
actions = {
deleteRule: jasmine.createSpy('deleteRule'),
deleteRule: jest.fn(),
};
});
......@@ -61,7 +61,7 @@ describe('Approvals ModalRuleRemove', () => {
expect(modal.exists()).toBe(true);
expect(modal.props()).toEqual(
jasmine.objectContaining({
expect.objectContaining({
modalModule: MODAL_MODULE,
modalId: TEST_MODAL_ID,
}),
......@@ -97,6 +97,6 @@ describe('Approvals ModalRuleRemove', () => {
const modal = wrapper.find(GlModalVuex);
modal.vm.$emit('ok', new Event('submit'));
expect(actions.deleteRule).toHaveBeenCalledWith(jasmine.anything(), TEST_RULE.id, undefined);
expect(actions.deleteRule).toHaveBeenCalledWith(expect.anything(), TEST_RULE.id, undefined);
});
});
......@@ -32,7 +32,7 @@ describe('EE approvals base module mutations', () => {
mutations[types.SET_APPROVAL_SETTINGS](state, settings);
expect(state).toEqual(jasmine.objectContaining(settings));
expect(state).toEqual(expect.objectContaining(settings));
});
});
});
......@@ -64,7 +64,7 @@ describe('EpicCreateComponent', () => {
vm.epicTitle = newEpicTitle;
expect(vm.setEpicCreateTitle).toHaveBeenCalledWith(
jasmine.objectContaining({
expect.objectContaining({
newEpicTitle,
}),
);
......
......@@ -39,7 +39,7 @@ describe('EpicSidebarComponent', () => {
vm.getDateFromMilestonesTooltip(dateTypes.start);
expect(epicUtils.getDateFromMilestonesTooltip).toHaveBeenCalledWith(
jasmine.objectContaining({
expect.objectContaining({
dateType: dateTypes.start,
}),
);
......@@ -53,7 +53,7 @@ describe('EpicSidebarComponent', () => {
vm.changeStartDateType(true, true);
expect(vm.toggleStartDateType).toHaveBeenCalledWith(
jasmine.objectContaining({
expect.objectContaining({
dateTypeIsFixed: true,
}),
);
......@@ -65,7 +65,7 @@ describe('EpicSidebarComponent', () => {
vm.changeStartDateType(true, false);
expect(vm.saveDate).toHaveBeenCalledWith(
jasmine.objectContaining({
expect.objectContaining({
dateTypeIsFixed: true,
dateType: dateTypes.start,
newDate: '2018-06-01',
......@@ -81,7 +81,7 @@ describe('EpicSidebarComponent', () => {
vm.saveStartDate('2018-1-1');
expect(vm.saveDate).toHaveBeenCalledWith(
jasmine.objectContaining({
expect.objectContaining({
dateTypeIsFixed: true,
dateType: dateTypes.start,
newDate: '2018-1-1',
......@@ -97,7 +97,7 @@ describe('EpicSidebarComponent', () => {
vm.changeDueDateType(true, true);
expect(vm.toggleDueDateType).toHaveBeenCalledWith(
jasmine.objectContaining({
expect.objectContaining({
dateTypeIsFixed: true,
}),
);
......@@ -109,7 +109,7 @@ describe('EpicSidebarComponent', () => {
vm.changeDueDateType(true, false);
expect(vm.saveDate).toHaveBeenCalledWith(
jasmine.objectContaining({
expect.objectContaining({
dateTypeIsFixed: true,
dateType: dateTypes.due,
newDate: '2018-08-01',
......@@ -125,7 +125,7 @@ describe('EpicSidebarComponent', () => {
vm.saveDueDate('2018-1-1');
expect(vm.saveDate).toHaveBeenCalledWith(
jasmine.objectContaining({
expect.objectContaining({
dateTypeIsFixed: true,
dateType: dateTypes.due,
newDate: '2018-1-1',
......
......@@ -54,7 +54,7 @@ describe('SidebarLabelsComponent', () => {
wrapper.vm.toggleSidebarRevealLabelsDropdown();
expect(wrapper.vm.toggleSidebar).toHaveBeenCalledWith(
jasmine.objectContaining({
expect.objectContaining({
sidebarCollapsed: false,
}),
);
......@@ -73,7 +73,7 @@ describe('SidebarLabelsComponent', () => {
expect(wrapper.vm.sidebarExpandedOnClick).toBe(false);
expect(wrapper.vm.toggleSidebar).toHaveBeenCalledWith(
jasmine.objectContaining({
expect.objectContaining({
sidebarCollapsed: false,
}),
);
......
......@@ -1055,8 +1055,8 @@ describe('Epic Store Actions', () => {
],
() => {
expect(epicUtils.gqClient.mutate).toHaveBeenCalledWith(
jasmine.objectContaining({
variables: jasmine.objectContaining({
expect.objectContaining({
variables: expect.objectContaining({
epicSetSubscriptionInput: {
iid: `${state.epicIid}`,
groupPath: state.fullPath,
......
......@@ -152,7 +152,7 @@ describe('AppComponent', () => {
vm.fetchNodeDetails(mockNode)
.then(() => {
expect(eventHub.$emit).toHaveBeenCalledWith('nodeDetailsLoaded', jasmine.any(Object));
expect(eventHub.$emit).toHaveBeenCalledWith('nodeDetailsLoaded', expect.any(Object));
const nodeDetails = vm.store.state.nodeDetails['1'];
expect(nodeDetails).toBeDefined();
......@@ -169,7 +169,7 @@ describe('AppComponent', () => {
vm.fetchNodeDetails(mockNode)
.then(() => {
expect(eventHub.$emit).toHaveBeenCalledWith('nodeDetailsLoaded', jasmine.any(Object));
expect(eventHub.$emit).toHaveBeenCalledWith('nodeDetailsLoaded', expect.any(Object));
const nodeDetails = vm.store.state.nodeDetails['1'];
expect(nodeDetails).toBeDefined();
......@@ -186,7 +186,7 @@ describe('AppComponent', () => {
vm.fetchNodeDetails(mockNode)
.then(() => {
expect(eventHub.$emit).toHaveBeenCalledWith('nodeDetailsLoaded', jasmine.any(Object));
expect(eventHub.$emit).toHaveBeenCalledWith('nodeDetailsLoaded', expect.any(Object));
const nodeDetails = vm.store.state.nodeDetails['1'];
expect(nodeDetails).toBeDefined();
......@@ -476,9 +476,9 @@ describe('AppComponent', () => {
it('binds event handler for `pollNodeDetails`', () => {
const vmX = createComponent();
expect(eventHub.$on).toHaveBeenCalledWith('pollNodeDetails', jasmine.any(Function));
expect(eventHub.$on).toHaveBeenCalledWith('showNodeActionModal', jasmine.any(Function));
expect(eventHub.$on).toHaveBeenCalledWith('repairNode', jasmine.any(Function));
expect(eventHub.$on).toHaveBeenCalledWith('pollNodeDetails', expect.any(Function));
expect(eventHub.$on).toHaveBeenCalledWith('showNodeActionModal', expect.any(Function));
expect(eventHub.$on).toHaveBeenCalledWith('repairNode', expect.any(Function));
vmX.$destroy();
});
});
......@@ -488,9 +488,9 @@ describe('AppComponent', () => {
const vmX = createComponent();
vmX.$destroy();
expect(eventHub.$off).toHaveBeenCalledWith('pollNodeDetails', jasmine.any(Function));
expect(eventHub.$off).toHaveBeenCalledWith('showNodeActionModal', jasmine.any(Function));
expect(eventHub.$off).toHaveBeenCalledWith('repairNode', jasmine.any(Function));
expect(eventHub.$off).toHaveBeenCalledWith('pollNodeDetails', expect.any(Function));
expect(eventHub.$off).toHaveBeenCalledWith('showNodeActionModal', expect.any(Function));
expect(eventHub.$off).toHaveBeenCalledWith('repairNode', expect.any(Function));
});
});
......
......@@ -130,7 +130,7 @@ describe('GeoNodeItemComponent', () => {
describe('created', () => {
it('binds `nodeDetailsLoaded` event handler', () => {
expect(eventHub.$on).toHaveBeenCalledWith('nodeDetailsLoaded', jasmine.any(Function));
expect(eventHub.$on).toHaveBeenCalledWith('nodeDetailsLoaded', expect.any(Function));
});
});
......@@ -138,7 +138,7 @@ describe('GeoNodeItemComponent', () => {
it('unbinds `nodeDetailsLoaded` event handler', () => {
wrapper.destroy();
expect(eventHub.$off).toHaveBeenCalledWith('nodeDetailsLoaded', jasmine.any(Function));
expect(eventHub.$off).toHaveBeenCalledWith('nodeDetailsLoaded', expect.any(Function));
});
});
......
......@@ -79,7 +79,7 @@ describe('GroupMemberStore', () => {
.fetchContributedMembers()
.then(() => {
expect(store.isLoading).toBe(false);
expect(store.setColumns).toHaveBeenCalledWith(jasmine.any(Object));
expect(store.setColumns).toHaveBeenCalledWith(expect.any(Object));
expect(store.setMembers).toHaveBeenCalledWith(rawMembers);
done();
})
......
......@@ -38,7 +38,7 @@ describe('IDE EERightPane', () => {
factory();
expect(wrapper.find(RightPane).props('extensionTabs')).toEqual([
jasmine.objectContaining({
expect.objectContaining({
show: true,
title: 'Terminal',
}),
......@@ -51,7 +51,7 @@ describe('IDE EERightPane', () => {
factory();
expect(wrapper.find(RightPane).props('extensionTabs')).toEqual([
jasmine.objectContaining({
expect.objectContaining({
show: false,
title: 'Terminal',
}),
......
......@@ -37,8 +37,8 @@ describe('EE IDE TerminalSession', () => {
session: { status: RUNNING, terminalPath: TEST_TERMINAL_PATH },
};
actions = {
restartSession: jasmine.createSpy('restartSession'),
stopSession: jasmine.createSpy('stopSession'),
restartSession: jest.fn(),
stopSession: jest.fn(),
};
});
......
......@@ -18,8 +18,8 @@ describe('EE IDE TerminalControls', () => {
factory();
expect(buttons.wrappers.map(x => x.props())).toEqual([
jasmine.objectContaining({ direction: 'up', disabled: true }),
jasmine.objectContaining({ direction: 'down', disabled: true }),
expect.objectContaining({ direction: 'up', disabled: true }),
expect.objectContaining({ direction: 'down', disabled: true }),
]);
});
......@@ -27,7 +27,7 @@ describe('EE IDE TerminalControls', () => {
factory({ propsData: { canScrollUp: true } });
expect(buttons.at(0).props()).toEqual(
jasmine.objectContaining({ direction: 'up', disabled: false }),
expect.objectContaining({ direction: 'up', disabled: false }),
);
});
......@@ -35,7 +35,7 @@ describe('EE IDE TerminalControls', () => {
factory({ propsData: { canScrollDown: true } });
expect(buttons.at(1).props()).toEqual(
jasmine.objectContaining({ direction: 'down', disabled: false }),
expect.objectContaining({ direction: 'down', disabled: false }),
);
});
......
......@@ -133,7 +133,7 @@ describe('EE IDE store terminal session controls actions', () => {
[],
[
{ type: 'requestStartSession' },
{ type: 'receiveStartSessionError', payload: jasmine.any(Error) },
{ type: 'receiveStartSessionError', payload: expect.any(Error) },
],
);
});
......@@ -200,7 +200,7 @@ describe('EE IDE store terminal session controls actions', () => {
[],
[
{ type: 'requestStopSession' },
{ type: 'receiveStopSessionError', payload: jasmine.any(Error) },
{ type: 'receiveStopSessionError', payload: expect.any(Error) },
],
);
});
......@@ -276,7 +276,7 @@ describe('EE IDE store terminal session controls actions', () => {
[],
[
{ type: 'requestStartSession' },
{ type: 'receiveStartSessionError', payload: jasmine.any(Error) },
{ type: 'receiveStartSessionError', payload: expect.any(Error) },
],
);
});
......
......@@ -74,8 +74,8 @@ describe('Insights store actions', () => {
actions.receiveConfigError,
null,
null,
jasmine.any(Array),
jasmine.any(Array),
expect.any(Array),
expect.any(Array),
() => {
expect(createFlash).toHaveBeenCalledWith(
`There was an error fetching configuration for charts: Unknown Error`,
......
......@@ -121,7 +121,7 @@ describe('extractGroupMilestones', () => {
expect(extractedMilestones.length).toBe(edges.length);
expect(extractedMilestones[0]).toEqual(
jasmine.objectContaining({
expect.objectContaining({
...edges[0].node,
}),
);
......
......@@ -46,7 +46,7 @@ describe('EE MRWidget approvals footer', () => {
expect(list.exists()).toBe(true);
expect(list.props()).toEqual(
jasmine.objectContaining({
expect.objectContaining({
approvalRules: testApprovalRules(),
}),
);
......@@ -69,7 +69,7 @@ describe('EE MRWidget approvals footer', () => {
expect(icon.exists()).toBe(true);
expect(icon.props()).toEqual(
jasmine.objectContaining({
expect.objectContaining({
name: 'chevron-down',
}),
);
......@@ -153,7 +153,7 @@ describe('EE MRWidget approvals footer', () => {
expect(avatars.exists()).toBe(true);
expect(avatars.props()).toEqual(
jasmine.objectContaining({
expect.objectContaining({
items: testSuggestedApprovers().filter((x, idx) => idx < 5),
breakpoint: 0,
emptyText: '',
......
......@@ -124,7 +124,7 @@ describe('EE MRWidget approvals list', () => {
expect(icon.exists()).toBe(true);
expect(icon.props()).toEqual(
jasmine.objectContaining({
expect.objectContaining({
isApproved: true,
}),
);
......@@ -140,7 +140,7 @@ describe('EE MRWidget approvals list', () => {
expect(approvers.exists()).toBe(true);
expect(approvers.props()).toEqual(
jasmine.objectContaining({
expect.objectContaining({
items: testApprovers(),
}),
);
......@@ -158,7 +158,7 @@ describe('EE MRWidget approvals list', () => {
expect(approvers.exists()).toBe(true);
expect(approvers.props()).toEqual(
jasmine.objectContaining({
expect.objectContaining({
items: rule.approved_by,
}),
);
......@@ -184,7 +184,7 @@ describe('EE MRWidget approvals list', () => {
expect(approvers.exists()).toBe(true);
expect(approvers.props()).toEqual(
jasmine.objectContaining({
expect.objectContaining({
items: rule.approvers,
}),
);
......@@ -195,7 +195,7 @@ describe('EE MRWidget approvals list', () => {
expect(approvedBy.exists()).toBe(true);
expect(approvedBy.props()).toEqual(
jasmine.objectContaining({
expect.objectContaining({
items: rule.approved_by,
}),
);
......@@ -219,7 +219,7 @@ describe('EE MRWidget approvals list', () => {
expect(icon.exists()).toBe(true);
expect(icon.props()).toEqual(
jasmine.objectContaining({
expect.objectContaining({
isApproved: false,
}),
);
......@@ -242,7 +242,7 @@ describe('EE MRWidget approvals list', () => {
expect(icon.exists()).toBe(true);
expect(icon.props()).toEqual(
jasmine.objectContaining({
expect.objectContaining({
isApproved: false,
}),
);
......
......@@ -47,7 +47,7 @@ describe('EE MRWidget approvals summary', () => {
expect(avatars.exists()).toBe(true);
expect(avatars.props()).toEqual(
jasmine.objectContaining({
expect.objectContaining({
items: testApprovers(),
}),
);
......
......@@ -31,7 +31,7 @@ describe('EE MRWidget approved icon', () => {
expect(icon.exists()).toBe(true);
expect(icon.props()).toEqual(
jasmine.objectContaining({
expect.objectContaining({
size: EXPECTED_SIZE,
name: 'mobile-issue-close',
}),
......
......@@ -28,7 +28,7 @@ describe('EE MR Widget mappers', () => {
const result = mapApprovalsResponse(data);
expect(result).toEqual(
jasmine.objectContaining({
expect.objectContaining({
approvalRuleNamesLeft: ['Lorem', 'Ipsum'],
}),
);
......@@ -43,7 +43,7 @@ describe('EE MR Widget mappers', () => {
const result = mapApprovalsResponse(data);
expect(result).toEqual(
jasmine.objectContaining({
expect.objectContaining({
approvalRuleNamesLeft: ['Lorem', 'Ipsum', 'License-Check', 'Vulnerability-Check'],
}),
);
......@@ -58,7 +58,7 @@ describe('EE MR Widget mappers', () => {
const result = mapApprovalsResponse(data);
expect(result).toEqual(
jasmine.objectContaining({
expect.objectContaining({
approvalRuleNamesLeft: ['Lorem', 'Ipsum', 'Code Owners'],
}),
);
......@@ -71,7 +71,7 @@ describe('EE MR Widget mappers', () => {
});
expect(result).toEqual(
jasmine.objectContaining({
expect.objectContaining({
approvalRuleNamesLeft: [],
}),
);
......@@ -87,7 +87,7 @@ describe('EE MR Widget mappers', () => {
const result = mapApprovalsResponse(data);
expect(result).toEqual(
jasmine.objectContaining({
expect.objectContaining({
approvalRuleNamesLeft: [],
}),
);
......
......@@ -391,7 +391,7 @@ describe('Security Reports modal', () => {
it('submits the comment and dismisses the vulnerability if text has been entered', () => {
const { vm } = wrapper;
vm.addCommentAndDismiss = jasmine.createSpy();
vm.addCommentAndDismiss = jest.fn();
vm.localDismissalComment = comment;
vm.handleDismissalCommentSubmission();
......@@ -415,7 +415,7 @@ describe('Security Reports modal', () => {
it('submits the comment if text is entered and the vulnerability is already dismissed', () => {
const { vm } = wrapper;
vm.addDismissalComment = jasmine.createSpy();
vm.addDismissalComment = jest.fn();
vm.localDismissalComment = comment;
vm.handleDismissalCommentSubmission();
......
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