Commit 3d5d9c19 authored by Fernando's avatar Fernando

Unit test feedback

* Refactor to not use array of table headers
* Use describe.each
* Add selector helpers
parent 5d7ea81e
...@@ -30,10 +30,6 @@ export default { ...@@ -30,10 +30,6 @@ export default {
data() { data() {
return { return {
formIsOpen: false, formIsOpen: false,
tableHeaders: [
{ className: 'section-70', label: s__('Licenses|Policy') },
{ className: 'section-30', label: s__('Licenses|Name') },
],
}; };
}, },
computed: { computed: {
...@@ -109,13 +105,8 @@ export default { ...@@ -109,13 +105,8 @@ export default {
</div> </div>
<template v-else> <template v-else>
<div <div class="table-section gl-d-flex gl-pl-2 section-70" role="rowheader">
class="table-section gl-d-flex gl-pl-2" {{ s__('Licenses|Policy') }}
:class="tableHeaders[0].className"
role="rowheader"
>
{{ tableHeaders[0].label }}
<gl-icon <gl-icon
v-if="isTooltipEnabled" v-if="isTooltipEnabled"
ref="reportInfo" ref="reportInfo"
...@@ -146,8 +137,8 @@ export default { ...@@ -146,8 +137,8 @@ export default {
</gl-popover> </gl-popover>
</div> </div>
<div class="table-section" :class="tableHeaders[1].className" role="rowheader"> <div class="table-section section-30" role="rowheader">
{{ tableHeaders[1].label }} {{ s__('Licenses|Name') }}
</div> </div>
</template> </template>
</template> </template>
......
...@@ -29,6 +29,8 @@ const PaginatedListMock = { ...@@ -29,6 +29,8 @@ const PaginatedListMock = {
}; };
const noop = () => {}; const noop = () => {};
const findIcon = () => wrapper.find(GlIcon);
const findPopover = () => wrapper.find(GlPopover);
const createComponent = ({ state, getters, props, actionMocks, isAdmin, options, provide }) => { const createComponent = ({ state, getters, props, actionMocks, isAdmin, options, provide }) => {
const fakeStore = new Vuex.Store({ const fakeStore = new Vuex.Store({
...@@ -205,8 +207,8 @@ describe('License Management', () => { ...@@ -205,8 +207,8 @@ describe('License Management', () => {
}, },
}); });
expect(wrapper.find(GlIcon).exists()).toBe(false); expect(findIcon().exists()).toBe(false);
expect(wrapper.find(GlPopover).exists()).toBe(false); expect(findPopover().exists()).toBe(false);
}); });
}); });
...@@ -217,8 +219,8 @@ describe('License Management', () => { ...@@ -217,8 +219,8 @@ describe('License Management', () => {
isAdmin: true, isAdmin: true,
}); });
expect(wrapper.find(GlIcon).exists()).toBe(false); expect(findIcon().exists()).toBe(false);
expect(wrapper.find(GlPopover).exists()).toBe(false); expect(findPopover().exists()).toBe(false);
}); });
}); });
}); });
...@@ -260,32 +262,23 @@ describe('License Management', () => { ...@@ -260,32 +262,23 @@ describe('License Management', () => {
}); });
}); });
describe('when licenseComplianceDeniesMr feature flag enabled', () => { describe.each([true, false])(
it('should show the developer only tooltip', () => { 'when licenseComplianceDeniesMr feature flag is %p',
createComponent({ licenseComplianceDeniesMr => {
state: { isLoadingManagedLicenses: false }, it('should show the developer only tooltip', () => {
isAdmin: false, createComponent({
provide: { state: { isLoadingManagedLicenses: false },
glFeatures: { licenseComplianceDeniesMr: true }, isAdmin: false,
}, provide: {
}); glFeatures: { licenseComplianceDeniesMr },
},
expect(wrapper.find(GlIcon).exists()).toBe(true); });
expect(wrapper.find(GlPopover).exists()).toBe(true);
});
});
describe('when licenseComplianceDeniesMr feature flag disabled', () => { expect(findIcon().exists()).toBe(licenseComplianceDeniesMr);
it('should not show the developer only tooltip', () => { expect(findPopover().exists()).toBe(licenseComplianceDeniesMr);
createComponent({
state: { isLoadingManagedLicenses: false },
isAdmin: false,
}); });
},
expect(wrapper.find(GlIcon).exists()).toBe(false); );
expect(wrapper.find(GlPopover).exists()).toBe(false);
});
});
}); });
}); });
}); });
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