Commit 4068599d authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch 'fc-validation-segment-remove-data-in-tests' into 'master'

Use mock apollo for validation segment tests

See merge request gitlab-org/gitlab!78070
parents e089bf40 edaeb2eb
import VueApollo from 'vue-apollo';
import { GlIcon } from '@gitlab/ui'; import { GlIcon } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount, createLocalVue } from '@vue/test-utils';
import { escape } from 'lodash'; import { escape } from 'lodash';
import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import createMockApollo from 'helpers/mock_apollo_helper';
import { sprintf } from '~/locale'; import { sprintf } from '~/locale';
import ValidationSegment, { import ValidationSegment, {
i18n, i18n,
} from '~/pipeline_editor/components/header/validation_segment.vue'; } from '~/pipeline_editor/components/header/validation_segment.vue';
import getAppStatus from '~/pipeline_editor/graphql/queries/client/app_status.query.graphql';
import { import {
CI_CONFIG_STATUS_INVALID, CI_CONFIG_STATUS_INVALID,
EDITOR_APP_STATUS_EMPTY, EDITOR_APP_STATUS_EMPTY,
...@@ -21,12 +24,29 @@ import { ...@@ -21,12 +24,29 @@ import {
mockYmlHelpPagePath, mockYmlHelpPagePath,
} from '../../mock_data'; } from '../../mock_data';
const localVue = createLocalVue();
localVue.use(VueApollo);
describe('Validation segment component', () => { describe('Validation segment component', () => {
let wrapper; let wrapper;
const createComponent = ({ props = {}, appStatus }) => { const mockApollo = createMockApollo();
const createComponent = ({ props = {}, appStatus = EDITOR_APP_STATUS_INVALID }) => {
mockApollo.clients.defaultClient.cache.writeQuery({
query: getAppStatus,
data: {
app: {
__typename: 'PipelineEditorApp',
status: appStatus,
},
},
});
wrapper = extendedWrapper( wrapper = extendedWrapper(
shallowMount(ValidationSegment, { shallowMount(ValidationSegment, {
localVue,
apolloProvider: mockApollo,
provide: { provide: {
ymlHelpPagePath: mockYmlHelpPagePath, ymlHelpPagePath: mockYmlHelpPagePath,
lintUnavailableHelpPagePath: mockLintUnavailableHelpPagePath, lintUnavailableHelpPagePath: mockLintUnavailableHelpPagePath,
...@@ -36,12 +56,6 @@ describe('Validation segment component', () => { ...@@ -36,12 +56,6 @@ describe('Validation segment component', () => {
ciFileContent: mockCiYml, ciFileContent: mockCiYml,
...props, ...props,
}, },
// Simulate graphQL client query result
data() {
return {
appStatus,
};
},
}), }),
); );
}; };
...@@ -99,6 +113,7 @@ describe('Validation segment component', () => { ...@@ -99,6 +113,7 @@ describe('Validation segment component', () => {
appStatus: EDITOR_APP_STATUS_INVALID, appStatus: EDITOR_APP_STATUS_INVALID,
}); });
}); });
it('has warning icon', () => { it('has warning icon', () => {
expect(findIcon().props('name')).toBe('warning-solid'); expect(findIcon().props('name')).toBe('warning-solid');
}); });
......
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