Commit 65b0ce17 authored by Mark Florian's avatar Mark Florian Committed by David O'Regan

Recover test lost due to rebase

This recovers the test added in 139e730a
that was lost due a bad rebase of this branch.
parent 0011a0e9
......@@ -15,6 +15,8 @@ jest.mock('~/lib/utils/url_utility');
Vue.use(VueApollo);
const projectPath = 'namespace/project';
describe('ManageViaMr component', () => {
let wrapper;
......@@ -37,7 +39,7 @@ describe('ManageViaMr component', () => {
wrapper = extendedWrapper(
mount(ManageViaMr, {
provide: {
projectPath: 'testProjectPath',
projectPath,
},
propsData: {
feature: {
......@@ -62,14 +64,18 @@ describe('ManageViaMr component', () => {
// the ones available in the current test context.
const supportedReportTypes = Object.entries(featureToMutationMap).map(
([featureType, { getMutationPayload, mutationId }]) => {
const { mutation } = getMutationPayload();
return [humanize(featureType), featureType, mutation, mutationId];
const { mutation, variables: mutationVariables } = getMutationPayload(projectPath);
return [humanize(featureType), featureType, mutation, mutationId, mutationVariables];
},
);
describe.each(supportedReportTypes)('%s', (featureName, featureType, mutation, mutationId) => {
const buildConfigureSecurityFeatureMock = buildConfigureSecurityFeatureMockFactory(mutationId);
const successHandler = async () => buildConfigureSecurityFeatureMock();
describe.each(supportedReportTypes)(
'%s',
(featureName, featureType, mutation, mutationId, mutationVariables) => {
const buildConfigureSecurityFeatureMock = buildConfigureSecurityFeatureMockFactory(
mutationId,
);
const successHandler = jest.fn(async () => buildConfigureSecurityFeatureMock());
const noSuccessPathHandler = async () =>
buildConfigureSecurityFeatureMock({
successPath: '',
......@@ -100,6 +106,13 @@ describe('ManageViaMr component', () => {
it('it does render a button', () => {
expect(findButton().exists()).toBe(true);
});
it('clicking on the button triggers the configure mutation', () => {
findButton().trigger('click');
expect(successHandler).toHaveBeenCalledTimes(1);
expect(successHandler).toHaveBeenCalledWith(mutationVariables);
});
});
describe('given a pending response', () => {
......@@ -153,7 +166,8 @@ describe('ManageViaMr component', () => {
expect(findButton().props('loading')).toBe(false);
});
});
});
},
);
describe('button props', () => {
it('passes the variant and category props to the GlButton', () => {
......
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