Commit 92f10950 authored by Samantha Ming's avatar Samantha Ming

Convert mr_rules_spec to a jest test

- move over jest test
- copy over mock test
parent 0f245d47
...@@ -6,7 +6,7 @@ import MRRules from 'ee/approvals/components/mr_edit/mr_rules.vue'; ...@@ -6,7 +6,7 @@ import MRRules from 'ee/approvals/components/mr_edit/mr_rules.vue';
import Rules from 'ee/approvals/components/rules.vue'; import Rules from 'ee/approvals/components/rules.vue';
import RuleControls from 'ee/approvals/components/rule_controls.vue'; import RuleControls from 'ee/approvals/components/rule_controls.vue';
import UserAvatarList from '~/vue_shared/components/user_avatar/user_avatar_list.vue'; import UserAvatarList from '~/vue_shared/components/user_avatar/user_avatar_list.vue';
import { createEmptyRule, createMRRule, createMRRuleWithSource } from '../../mocks'; import { createEmptyRule, createMRRule, createMRRuleWithSource } from '../../mock_data';
const { HEADERS } = Rules; const { HEADERS } = Rules;
...@@ -26,6 +26,7 @@ describe('EE Approvals MRRules', () => { ...@@ -26,6 +26,7 @@ describe('EE Approvals MRRules', () => {
wrapper = mount(localVue.extend(MRRules), { wrapper = mount(localVue.extend(MRRules), {
localVue, localVue,
store: new Vuex.Store(store), store: new Vuex.Store(store),
attachToDocument: true,
}); });
}; };
...@@ -44,7 +45,7 @@ describe('EE Approvals MRRules', () => { ...@@ -44,7 +45,7 @@ describe('EE Approvals MRRules', () => {
hasLoaded: true, hasLoaded: true,
rules: [], rules: [],
}; };
store.modules.approvals.actions.putRule = jasmine.createSpy('putRule'); store.modules.approvals.actions.putRule = jest.fn();
}); });
afterEach(() => { afterEach(() => {
......
export const createMRRule = () => ({
id: 7,
name: 'Amit',
approvers: [{ id: 1 }, { id: 2 }],
approvalsRequired: 2,
minApprovalsRequired: 0,
ruleType: 'regular',
});
export const createEmptyRule = () => ({
id: 5,
name: 'All Members',
approvers: [],
approvalsRequired: 3,
minApprovalsRequired: 0,
ruleType: 'any_approver',
});
export const createMRRuleWithSource = () => ({
...createEmptyRule(),
...createMRRule(),
minApprovalsRequired: 1,
hasSource: true,
sourceId: 3,
});
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