Commit d0cb0852 authored by Tristan Read's avatar Tristan Read Committed by Peter Leitzen

Add specs for issue type selector

parent 6501c882
...@@ -39,7 +39,7 @@ describe('Issue type field component', () => { ...@@ -39,7 +39,7 @@ describe('Issue type field component', () => {
const findTypeFromDropDownItemIconAt = (at) => const findTypeFromDropDownItemIconAt = (at) =>
findTypeFromDropDownItems().at(at).findComponent(GlIcon); findTypeFromDropDownItems().at(at).findComponent(GlIcon);
const createComponent = ({ data } = {}) => { const createComponent = ({ data } = {}, provide) => {
fakeApollo = createMockApollo([], mockResolvers); fakeApollo = createMockApollo([], mockResolvers);
wrapper = shallowMount(IssueTypeField, { wrapper = shallowMount(IssueTypeField, {
...@@ -51,6 +51,10 @@ describe('Issue type field component', () => { ...@@ -51,6 +51,10 @@ describe('Issue type field component', () => {
...data, ...data,
}; };
}, },
provide: {
canCreateIncident: true,
...provide,
},
}); });
}; };
...@@ -92,5 +96,25 @@ describe('Issue type field component', () => { ...@@ -92,5 +96,25 @@ describe('Issue type field component', () => {
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
expect(findTypeFromDropDown().attributes('value')).toBe(IssuableTypes.incident); expect(findTypeFromDropDown().attributes('value')).toBe(IssuableTypes.incident);
}); });
describe('when user is a guest', () => {
it('hides the incident type from the dropdown', async () => {
createComponent({}, { canCreateIncident: false, issueType: 'issue' });
await waitForPromises();
expect(findTypeFromDropDownItemAt(0).isVisible()).toBe(true);
expect(findTypeFromDropDownItemAt(1).isVisible()).toBe(false);
expect(findTypeFromDropDown().attributes('value')).toBe(IssuableTypes.issue);
});
it('and incident is selected, includes incident in the dropdown', async () => {
createComponent({}, { canCreateIncident: false, issueType: 'incident' });
await waitForPromises();
expect(findTypeFromDropDownItemAt(0).isVisible()).toBe(true);
expect(findTypeFromDropDownItemAt(1).isVisible()).toBe(true);
expect(findTypeFromDropDown().attributes('value')).toBe(IssuableTypes.incident);
});
});
}); });
}); });
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