Commit 5001ca25 authored by Justin Ho's avatar Justin Ho

Use full state for setting isInheriting

Instead of using a mock for computed props
parent ef9ed59d
......@@ -23,13 +23,14 @@ describe('JiraIssuesFields', () => {
];
const createComponent = (mountFn) => ({ isInheriting = false, props } = {}) => {
store = createStore({
defaultState: isInheriting ? {} : undefined,
});
return extendedWrapper(
mountFn(JiraIssueCreationVulnerabilities, {
store,
propsData: { ...defaultProps, ...props },
computed: {
isInheriting: () => isInheriting,
},
}),
);
};
......@@ -48,10 +49,6 @@ describe('JiraIssuesFields', () => {
const setEnableJiraVulnerabilitiesChecked = (isChecked) =>
findEnableJiraVulnerabilities().vm.$emit('input', isChecked);
beforeEach(() => {
store = createStore();
});
afterEach(() => {
wrapper.destroy();
});
......@@ -145,8 +142,8 @@ describe('JiraIssuesFields', () => {
describe('with Jira issues fetching in progress', () => {
beforeEach(async () => {
store.state.isLoadingJiraIssueTypes = true;
wrapper = createShallowComponent();
store.state.isLoadingJiraIssueTypes = true;
await setEnableJiraVulnerabilitiesChecked(true);
});
......@@ -160,8 +157,8 @@ describe('JiraIssuesFields', () => {
describe('with Jira issues fetched', () => {
beforeEach(async () => {
store.state.jiraIssueTypes = TEST_JIRA_ISSUE_TYPES;
wrapper = createShallowComponent({ props: { projectKey: 'TES' } });
store.state.jiraIssueTypes = TEST_JIRA_ISSUE_TYPES;
await setEnableJiraVulnerabilitiesChecked(true);
});
......@@ -186,8 +183,8 @@ describe('JiraIssuesFields', () => {
describe('with Jira issue fetch failure', () => {
beforeEach(async () => {
store.state.loadingJiraIssueTypesErrorMessage = 'something went wrong';
wrapper = createShallowComponent();
store.state.loadingJiraIssueTypesErrorMessage = 'something went wrong';
await setEnableJiraVulnerabilitiesChecked(true);
});
......
......@@ -3,8 +3,10 @@ import { mount } from '@vue/test-utils';
import JiraIssuesFields from '~/integrations/edit/components/jira_issues_fields.vue';
import JiraUpgradeCta from '~/integrations/edit/components/jira_upgrade_cta.vue';
import eventHub from '~/integrations/edit/event_hub';
import { createStore } from '~/integrations/edit/store';
describe('JiraIssuesFields', () => {
let store;
let wrapper;
const defaultProps = {
......@@ -14,8 +16,13 @@ describe('JiraIssuesFields', () => {
};
const createComponent = ({ isInheriting = false, props, ...options } = {}) => {
store = createStore({
defaultState: isInheriting ? {} : undefined,
});
wrapper = mount(JiraIssuesFields, {
propsData: { ...defaultProps, ...props },
store,
stubs: ['jira-issue-creation-vulnerabilities'],
computed: {
isInheriting: () => isInheriting,
......@@ -87,9 +94,11 @@ describe('JiraIssuesFields', () => {
});
it('renders disabled project_key input', () => {
expect(findProjectKey().exists()).toBe(true);
expect(findProjectKey().attributes('disabled')).toBe('disabled');
expect(findProjectKey().attributes('required')).toBeUndefined();
const projectKey = findProjectKey();
expect(projectKey.exists()).toBe(true);
expect(projectKey.attributes('disabled')).toBe('disabled');
expect(projectKey.attributes('required')).toBeUndefined();
});
it('does not show upgrade banner', () => {
......
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