Commit 4f3a04eb authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch 'himkp-jet' into 'master'

Migrate some files in ee/spec/javascripts/approvals/ to Jest

See merge request gitlab-org/gitlab!31443
parents c0159a2b 66a10e9d
...@@ -78,7 +78,7 @@ describe('Approvals ModalRuleCreate', () => { ...@@ -78,7 +78,7 @@ describe('Approvals ModalRuleCreate', () => {
factory(); factory();
const form = wrapper.find(RuleForm); const form = wrapper.find(RuleForm);
form.vm.submit = jasmine.createSpy('submit'); form.vm.submit = jest.fn();
const modal = wrapper.find(GlModalVuex); const modal = wrapper.find(GlModalVuex);
modal.vm.$emit('ok', new Event('ok')); modal.vm.$emit('ok', new Event('ok'));
......
...@@ -95,7 +95,7 @@ describe('EE Approvlas MRRulesHiddenInputs', () => { ...@@ -95,7 +95,7 @@ describe('EE Approvlas MRRulesHiddenInputs', () => {
factory(); factory();
expect(findHiddenInputs()).toEqual( expect(findHiddenInputs()).toEqual(
jasmine.arrayContaining([ expect.arrayContaining([
{ name: INPUT_ID, value: '4' }, { name: INPUT_ID, value: '4' },
{ name: INPUT_DELETE, value: '1' }, { name: INPUT_DELETE, value: '1' },
{ name: INPUT_ID, value: '7' }, { name: INPUT_ID, value: '7' },
...@@ -177,10 +177,14 @@ describe('EE Approvlas MRRulesHiddenInputs', () => { ...@@ -177,10 +177,14 @@ describe('EE Approvlas MRRulesHiddenInputs', () => {
it('renders source id input', () => { it('renders source id input', () => {
factory(); factory();
expect(findHiddenInputs()).toContain({ expect(findHiddenInputs()).toEqual(
name: INPUT_SOURCE_ID, expect.arrayContaining([
value: rule.sourceId.toString(), {
}); name: INPUT_SOURCE_ID,
value: rule.sourceId.toString(),
},
]),
);
}); });
}); });
}); });
...@@ -193,10 +197,14 @@ describe('EE Approvlas MRRulesHiddenInputs', () => { ...@@ -193,10 +197,14 @@ describe('EE Approvlas MRRulesHiddenInputs', () => {
it('renders input to remove hidden groups', () => { it('renders input to remove hidden groups', () => {
factory(); factory();
expect(findHiddenInputs()).toContain({ expect(findHiddenInputs()).toEqual(
name: INPUT_REMOVE_HIDDEN_GROUPS, expect.arrayContaining([
value: 'true', {
}); name: INPUT_REMOVE_HIDDEN_GROUPS,
value: 'true',
},
]),
);
}); });
}); });
}); });
......
...@@ -39,7 +39,7 @@ describe('EE Approvals RuleControls', () => { ...@@ -39,7 +39,7 @@ describe('EE Approvals RuleControls', () => {
beforeEach(() => { beforeEach(() => {
store = createStoreOptions(MREditModule()); store = createStoreOptions(MREditModule());
({ actions } = store.modules.approvals); ({ actions } = store.modules.approvals);
['requestEditRule', 'requestDeleteRule'].forEach(actionName => spyOn(actions, actionName)); ['requestEditRule', 'requestDeleteRule'].forEach(actionName => jest.spyOn(actions, actionName));
}); });
afterEach(() => { afterEach(() => {
...@@ -69,7 +69,7 @@ describe('EE Approvals RuleControls', () => { ...@@ -69,7 +69,7 @@ describe('EE Approvals RuleControls', () => {
button.vm.$emit('click'); button.vm.$emit('click');
expect(store.modules.approvals.actions.requestEditRule).toHaveBeenCalledWith( expect(store.modules.approvals.actions.requestEditRule).toHaveBeenCalledWith(
jasmine.anything(), expect.anything(),
TEST_RULE, TEST_RULE,
undefined, undefined,
); );
...@@ -94,7 +94,7 @@ describe('EE Approvals RuleControls', () => { ...@@ -94,7 +94,7 @@ describe('EE Approvals RuleControls', () => {
button.vm.$emit('click'); button.vm.$emit('click');
expect(store.modules.approvals.actions.requestDeleteRule).toHaveBeenCalledWith( expect(store.modules.approvals.actions.requestDeleteRule).toHaveBeenCalledWith(
jasmine.anything(), expect.anything(),
TEST_RULE, TEST_RULE,
undefined, undefined,
); );
......
...@@ -79,7 +79,7 @@ describe('EE Approvals RuleForm', () => { ...@@ -79,7 +79,7 @@ describe('EE Approvals RuleForm', () => {
store = createStoreOptions(projectSettingsModule(), { projectId: TEST_PROJECT_ID }); store = createStoreOptions(projectSettingsModule(), { projectId: TEST_PROJECT_ID });
['postRule', 'putRule', 'deleteRule', 'putFallbackRule'].forEach(actionName => { ['postRule', 'putRule', 'deleteRule', 'putFallbackRule'].forEach(actionName => {
spyOn(store.modules.approvals.actions, actionName); jest.spyOn(store.modules.approvals.actions, actionName).mockImplementation(() => {});
}); });
({ actions } = store.modules.approvals); ({ actions } = store.modules.approvals);
...@@ -166,7 +166,7 @@ describe('EE Approvals RuleForm', () => { ...@@ -166,7 +166,7 @@ describe('EE Approvals RuleForm', () => {
wrapper.vm.submit(); wrapper.vm.submit();
expect(actions.postRule).toHaveBeenCalledWith(jasmine.anything(), expected, undefined); expect(actions.postRule).toHaveBeenCalledWith(expect.anything(), expected, undefined);
}); });
}); });
}); });
...@@ -266,7 +266,7 @@ describe('EE Approvals RuleForm', () => { ...@@ -266,7 +266,7 @@ describe('EE Approvals RuleForm', () => {
wrapper.vm.submit(); wrapper.vm.submit();
expect(actions.postRule).toHaveBeenCalledWith(jasmine.anything(), expected, undefined); expect(actions.postRule).toHaveBeenCalledWith(expect.anything(), expected, undefined);
}); });
it('adds selected approvers on selection', () => { it('adds selected approvers on selection', () => {
...@@ -319,7 +319,7 @@ describe('EE Approvals RuleForm', () => { ...@@ -319,7 +319,7 @@ describe('EE Approvals RuleForm', () => {
wrapper.vm.submit(); wrapper.vm.submit();
expect(actions.putRule).toHaveBeenCalledWith(jasmine.anything(), expected, undefined); expect(actions.putRule).toHaveBeenCalledWith(expect.anything(), expected, undefined);
}); });
}); });
...@@ -346,7 +346,7 @@ describe('EE Approvals RuleForm', () => { ...@@ -346,7 +346,7 @@ describe('EE Approvals RuleForm', () => {
it('puts fallback rule', () => { it('puts fallback rule', () => {
expect(actions.putFallbackRule).toHaveBeenCalledWith( expect(actions.putFallbackRule).toHaveBeenCalledWith(
jasmine.anything(), expect.anything(),
{ approvalsRequired: TEST_APPROVALS_REQUIRED }, { approvalsRequired: TEST_APPROVALS_REQUIRED },
undefined, undefined,
); );
...@@ -434,8 +434,8 @@ describe('EE Approvals RuleForm', () => { ...@@ -434,8 +434,8 @@ describe('EE Approvals RuleForm', () => {
wrapper.vm.submit(); wrapper.vm.submit();
expect(actions.putRule).toHaveBeenCalledWith( expect(actions.putRule).toHaveBeenCalledWith(
jasmine.anything(), expect.anything(),
jasmine.objectContaining({ expect.objectContaining({
removeHiddenGroups: false, removeHiddenGroups: false,
}), }),
undefined, undefined,
...@@ -451,8 +451,8 @@ describe('EE Approvals RuleForm', () => { ...@@ -451,8 +451,8 @@ describe('EE Approvals RuleForm', () => {
wrapper.vm.submit(); wrapper.vm.submit();
expect(actions.putRule).toHaveBeenCalledWith( expect(actions.putRule).toHaveBeenCalledWith(
jasmine.anything(), expect.anything(),
jasmine.objectContaining({ expect.objectContaining({
removeHiddenGroups: true, removeHiddenGroups: true,
}), }),
undefined, undefined,
...@@ -533,8 +533,8 @@ describe('EE Approvals RuleForm', () => { ...@@ -533,8 +533,8 @@ describe('EE Approvals RuleForm', () => {
it('posts new rule', () => { it('posts new rule', () => {
expect(actions.postRule).toHaveBeenCalledWith( expect(actions.postRule).toHaveBeenCalledWith(
jasmine.anything(), expect.anything(),
jasmine.objectContaining({ expect.objectContaining({
approvalsRequired: TEST_APPROVALS_REQUIRED, approvalsRequired: TEST_APPROVALS_REQUIRED,
users: TEST_APPROVERS.map(x => x.id), users: TEST_APPROVERS.map(x => x.id),
}), }),
...@@ -552,7 +552,7 @@ describe('EE Approvals RuleForm', () => { ...@@ -552,7 +552,7 @@ describe('EE Approvals RuleForm', () => {
it('puts fallback rule', () => { it('puts fallback rule', () => {
expect(actions.putFallbackRule).toHaveBeenCalledWith( expect(actions.putFallbackRule).toHaveBeenCalledWith(
jasmine.anything(), expect.anything(),
{ approvalsRequired: TEST_APPROVALS_REQUIRED }, { approvalsRequired: TEST_APPROVALS_REQUIRED },
undefined, undefined,
); );
...@@ -579,7 +579,7 @@ describe('EE Approvals RuleForm', () => { ...@@ -579,7 +579,7 @@ describe('EE Approvals RuleForm', () => {
it('deletes rule', () => { it('deletes rule', () => {
expect(actions.deleteRule).toHaveBeenCalledWith( expect(actions.deleteRule).toHaveBeenCalledWith(
jasmine.anything(), expect.anything(),
TEST_RULE.id, TEST_RULE.id,
undefined, undefined,
); );
...@@ -587,7 +587,7 @@ describe('EE Approvals RuleForm', () => { ...@@ -587,7 +587,7 @@ describe('EE Approvals RuleForm', () => {
it('puts fallback rule', () => { it('puts fallback rule', () => {
expect(actions.putFallbackRule).toHaveBeenCalledWith( expect(actions.putFallbackRule).toHaveBeenCalledWith(
jasmine.anything(), expect.anything(),
{ approvalsRequired: TEST_APPROVALS_REQUIRED }, { approvalsRequired: TEST_APPROVALS_REQUIRED },
undefined, undefined,
); );
...@@ -605,8 +605,8 @@ describe('EE Approvals RuleForm', () => { ...@@ -605,8 +605,8 @@ describe('EE Approvals RuleForm', () => {
it('puts rule', () => { it('puts rule', () => {
expect(actions.putRule).toHaveBeenCalledWith( expect(actions.putRule).toHaveBeenCalledWith(
jasmine.anything(), expect.anything(),
jasmine.objectContaining({ expect.objectContaining({
id: TEST_RULE.id, id: TEST_RULE.id,
name: 'Bogus', name: 'Bogus',
approvalsRequired: TEST_APPROVALS_REQUIRED, approvalsRequired: TEST_APPROVALS_REQUIRED,
......
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