Commit 3326fe4d authored by Nicolò Maria Mezzopera's avatar Nicolò Maria Mezzopera Committed by Olena Horal-Koretska

Add unit test for group in composer install command

parent 3e517406
...@@ -31,8 +31,7 @@ export default { ...@@ -31,8 +31,7 @@ export default {
</script> </script>
<template> <template>
<div> <div v-if="groupExists" data-testid="root-node">
<div v-if="groupExists">
<h3 class="gl-font-lg">{{ __('Installation') }}</h3> <h3 class="gl-font-lg">{{ __('Installation') }}</h3>
<code-instruction <code-instruction
...@@ -60,5 +59,4 @@ export default { ...@@ -60,5 +59,4 @@ export default {
</gl-sprintf> </gl-sprintf>
</span> </span>
</div> </div>
</div>
</template> </template>
...@@ -12,24 +12,23 @@ localVue.use(Vuex); ...@@ -12,24 +12,23 @@ localVue.use(Vuex);
describe('ComposerInstallation', () => { describe('ComposerInstallation', () => {
let wrapper; let wrapper;
let store;
const composerRegistryIncludeStr = 'foo/registry'; const composerRegistryIncludeStr = 'foo/registry';
const composerPackageIncludeStr = 'foo/package'; const composerPackageIncludeStr = 'foo/package';
const groupExists = true;
const store = new Vuex.Store({ const createStore = (groupExists = true) => {
state: { store = new Vuex.Store({
packageEntity, state: { packageEntity, composerHelpPath },
composerHelpPath,
groupExists,
},
getters: { getters: {
composerRegistryInclude: () => composerRegistryIncludeStr, composerRegistryInclude: () => composerRegistryIncludeStr,
composerPackageInclude: () => composerPackageIncludeStr, composerPackageInclude: () => composerPackageIncludeStr,
groupExists: () => groupExists, groupExists: () => groupExists,
}, },
}); });
};
const findRootNode = () => wrapper.find('[data-testid="root-node"]');
const findRegistryInclude = () => wrapper.find('[data-testid="registry-include"]'); const findRegistryInclude = () => wrapper.find('[data-testid="registry-include"]');
const findPackageInclude = () => wrapper.find('[data-testid="package-include"]'); const findPackageInclude = () => wrapper.find('[data-testid="package-include"]');
const findHelpText = () => wrapper.find('[data-testid="help-text"]'); const findHelpText = () => wrapper.find('[data-testid="help-text"]');
...@@ -45,15 +44,16 @@ describe('ComposerInstallation', () => { ...@@ -45,15 +44,16 @@ describe('ComposerInstallation', () => {
}); });
} }
beforeEach(() => {
createComponent();
});
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
}); });
describe('registry include command', () => { describe('registry include command', () => {
beforeEach(() => {
createStore();
createComponent();
});
it('uses code_instructions', () => { it('uses code_instructions', () => {
const registryIncludeCommand = findRegistryInclude(); const registryIncludeCommand = findRegistryInclude();
expect(registryIncludeCommand.exists()).toBe(true); expect(registryIncludeCommand.exists()).toBe(true);
...@@ -70,6 +70,11 @@ describe('ComposerInstallation', () => { ...@@ -70,6 +70,11 @@ describe('ComposerInstallation', () => {
}); });
describe('package include command', () => { describe('package include command', () => {
beforeEach(() => {
createStore();
createComponent();
});
it('uses code_instructions', () => { it('uses code_instructions', () => {
const registryIncludeCommand = findPackageInclude(); const registryIncludeCommand = findPackageInclude();
expect(registryIncludeCommand.exists()).toBe(true); expect(registryIncludeCommand.exists()).toBe(true);
...@@ -94,4 +99,20 @@ describe('ComposerInstallation', () => { ...@@ -94,4 +99,20 @@ describe('ComposerInstallation', () => {
}); });
}); });
}); });
describe('root node', () => {
it('is normally rendered', () => {
createStore();
createComponent();
expect(findRootNode().exists()).toBe(true);
});
it('is not rendered when the group does not exist', () => {
createStore(false);
createComponent();
expect(findRootNode().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