Commit ec3095b4 authored by mfluharty's avatar mfluharty

Combine createComponent, createComponentWithApollo

Pass in withApollo argument instead
parent 18d53035
...@@ -19,8 +19,10 @@ describe('Test coverage table component', () => { ...@@ -19,8 +19,10 @@ describe('Test coverage table component', () => {
const findTotalCoverages = () => wrapper.find('.js-metric-card-item:nth-child(3) h3'); const findTotalCoverages = () => wrapper.find('.js-metric-card-item:nth-child(3) h3');
const findLoadingState = () => wrapper.find(GlSkeletonLoading); const findLoadingState = () => wrapper.find(GlSkeletonLoading);
const createComponent = ({ data = {} } = {}) => { const createComponent = ({ data = {} } = {}, withApollo = false) => {
wrapper = mount(TestCoverageSummary, { fakeApollo = createMockApollo([[getGroupTestCoverage, jest.fn().mockResolvedValue()]]);
const props = {
localVue, localVue,
data() { data() {
return { return {
...@@ -32,7 +34,12 @@ describe('Test coverage table component', () => { ...@@ -32,7 +34,12 @@ describe('Test coverage table component', () => {
...data, ...data,
}; };
}, },
mocks: { };
if (withApollo) {
localVue.use(VueApollo);
props.apolloProvider = fakeApollo;
} else {
props.mocks = {
$apollo: { $apollo: {
queries: { queries: {
group: { group: {
...@@ -40,28 +47,10 @@ describe('Test coverage table component', () => { ...@@ -40,28 +47,10 @@ describe('Test coverage table component', () => {
}, },
}, },
}, },
}, };
}); }
};
const createComponentWithApollo = ({ data = {} } = {}) => { wrapper = mount(TestCoverageSummary, props);
localVue.use(VueApollo);
fakeApollo = createMockApollo([[getGroupTestCoverage, jest.fn().mockResolvedValue()]]);
wrapper = mount(TestCoverageSummary, {
localVue,
data() {
return {
projectCount: null,
averageCoverage: null,
coverageCount: null,
hasError: false,
isLoading: false,
...data,
};
},
apolloProvider: fakeApollo,
});
}; };
afterEach(() => { afterEach(() => {
...@@ -109,7 +98,8 @@ describe('Test coverage table component', () => { ...@@ -109,7 +98,8 @@ describe('Test coverage table component', () => {
describe('when group has no coverage', () => { describe('when group has no coverage', () => {
it('renders empty metrics', async () => { it('renders empty metrics', async () => {
createComponentWithApollo({ createComponent({
withApollo: true,
data: {}, data: {},
queryData: { queryData: {
data: { data: {
......
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