Commit 47e875ea authored by Phil Hughes's avatar Phil Hughes

Added spec for rendering the selector

[ci skip]
parent 0820aab4
...@@ -149,7 +149,8 @@ export default { ...@@ -149,7 +149,8 @@ export default {
<form-component <form-component
v-if="canUpdate && showForm" v-if="canUpdate && showForm"
:form-state="formState" :form-state="formState"
:can-destroy="canDestroy" /> :can-destroy="canDestroy"
:issuable-templates="issuableTemplates" />
<div v-else> <div v-else>
<title-component <title-component
:issuable-ref="issuableRef" :issuable-ref="issuableRef"
......
...@@ -16,16 +16,27 @@ ...@@ -16,16 +16,27 @@
components: { components: {
descriptionTemplate, descriptionTemplate,
}, },
computed: {
hasIssuableTemplates() {
return this.issuableTemplates.length !== 0;
},
},
}; };
</script> </script>
<template> <template>
<fieldset class="row"> <fieldset class="row">
<div class="col-sm-4 col-lg-3"> <div
class="col-sm-4 col-lg-3"
v-if="hasIssuableTemplates">
<description-template <description-template
:issuable-templates="issuableTemplates" /> :issuable-templates="issuableTemplates" />
</div> </div>
<div class="col-sm-8 col-lg-9"> <div
:class="{
'col-sm-8 col-lg-9': hasIssuableTemplates,
'col-xs-12': !hasIssuableTemplates,
}">
<label <label
class="sr-only" class="sr-only"
for="issue-title"> for="issue-title">
......
import Vue from 'vue'; import Vue from 'vue';
import Store from '~/issue_show/stores'; import Store from '~/issue_show/stores';
import titleField from '~/issue_show/components/fields/title.vue'; import titleField from '~/issue_show/components/fields/title.vue';
import '~/templates/issuable_template_selectors';
describe('Title field component', () => { describe('Title field component', () => {
let vm; let vm;
...@@ -27,4 +28,23 @@ describe('Title field component', () => { ...@@ -27,4 +28,23 @@ describe('Title field component', () => {
vm.$el.querySelector('.form-control').value, vm.$el.querySelector('.form-control').value,
).toBe('test'); ).toBe('test');
}); });
it('does not render template selector if no templates exist', () => {
expect(
vm.$el.querySelector('.js-issuable-selector-wrap'),
).toBeNull();
});
it('renders template selector when templates exists', (done) => {
spyOn(gl, 'IssuableTemplateSelectors');
vm.issuableTemplates = ['test'];
Vue.nextTick(() => {
expect(
vm.$el.querySelector('.js-issuable-selector-wrap'),
).not.toBeNull();
done();
});
});
}); });
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