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