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