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