Commit 877a700e authored by Dave Pisek's avatar Dave Pisek

Reviewer feedback: Use withApollo factory

parent 0dd9d2ef
...@@ -41,11 +41,7 @@ describe('Pipeline Security Dashboard component', () => { ...@@ -41,11 +41,7 @@ describe('Pipeline Security Dashboard component', () => {
const findVulnerabilityReport = () => wrapper.findComponent(VulnerabilityReport); const findVulnerabilityReport = () => wrapper.findComponent(VulnerabilityReport);
const findScanErrorsAlert = () => wrapper.findComponent(ScanErrorsAlert); const findScanErrorsAlert = () => wrapper.findComponent(ScanErrorsAlert);
const factory = ({ stubs, provide, requestHandlers } = {}) => { const factory = ({ stubs, provide, apolloProvider } = {}) => {
if (requestHandlers) {
localVue.use(VueApollo);
}
store = new Vuex.Store({ store = new Vuex.Store({
modules: { modules: {
vulnerabilities: { vulnerabilities: {
...@@ -67,7 +63,7 @@ describe('Pipeline Security Dashboard component', () => { ...@@ -67,7 +63,7 @@ describe('Pipeline Security Dashboard component', () => {
wrapper = shallowMount(PipelineSecurityDashboard, { wrapper = shallowMount(PipelineSecurityDashboard, {
localVue, localVue,
...(requestHandlers && { apolloProvider: createMockApollo(requestHandlers) }), apolloProvider,
store, store,
provide: { provide: {
projectId, projectId,
...@@ -88,6 +84,12 @@ describe('Pipeline Security Dashboard component', () => { ...@@ -88,6 +84,12 @@ describe('Pipeline Security Dashboard component', () => {
}); });
}; };
const factoryWithApollo = ({ requestHandlers }) => {
localVue.use(VueApollo);
factory({ apolloProvider: createMockApollo(requestHandlers) });
};
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
}); });
...@@ -160,7 +162,7 @@ describe('Pipeline Security Dashboard component', () => { ...@@ -160,7 +162,7 @@ describe('Pipeline Security Dashboard component', () => {
describe('scans error alert', () => { describe('scans error alert', () => {
describe('with errors', () => { describe('with errors', () => {
beforeEach(() => { beforeEach(() => {
factory({ factoryWithApollo({
requestHandlers: [ requestHandlers: [
[ [
pipelineSecurityReportSummaryQuery, pipelineSecurityReportSummaryQuery,
...@@ -177,7 +179,7 @@ describe('Pipeline Security Dashboard component', () => { ...@@ -177,7 +179,7 @@ describe('Pipeline Security Dashboard component', () => {
describe('without errors', () => { describe('without errors', () => {
beforeEach(() => { beforeEach(() => {
factory({ factoryWithApollo({
requestHandlers: [ requestHandlers: [
[ [
pipelineSecurityReportSummaryQuery, pipelineSecurityReportSummaryQuery,
...@@ -201,7 +203,7 @@ describe('Pipeline Security Dashboard component', () => { ...@@ -201,7 +203,7 @@ describe('Pipeline Security Dashboard component', () => {
`( `(
'shows the summary is "$shouldShowReportSummary"', 'shows the summary is "$shouldShowReportSummary"',
async ({ response, shouldShowReportSummary }) => { async ({ response, shouldShowReportSummary }) => {
factory({ factoryWithApollo({
requestHandlers: [ requestHandlers: [
[pipelineSecurityReportSummaryQuery, jest.fn().mockResolvedValueOnce(response)], [pipelineSecurityReportSummaryQuery, jest.fn().mockResolvedValueOnce(response)],
], ],
......
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