Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/work_items/components/work_item_state_toggle_spec.js')
-rw-r--r--spec/frontend/work_items/components/work_item_state_toggle_spec.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/frontend/work_items/components/work_item_state_toggle_spec.js b/spec/frontend/work_items/components/work_item_state_toggle_spec.js
index a210bd50422..988df402d60 100644
--- a/spec/frontend/work_items/components/work_item_state_toggle_spec.js
+++ b/spec/frontend/work_items/components/work_item_state_toggle_spec.js
@@ -32,6 +32,7 @@ describe('Work Item State toggle button component', () => {
canUpdate = true,
workItemState = STATE_OPEN,
workItemType = 'Task',
+ hasComment = false,
} = {}) => {
wrapper = shallowMount(WorkItemStateToggle, {
apolloProvider: createMockApollo([[updateWorkItemMutation, mutationHandler]]),
@@ -40,6 +41,7 @@ describe('Work Item State toggle button component', () => {
workItemState,
workItemType,
canUpdate,
+ hasComment,
},
});
};
@@ -61,6 +63,23 @@ describe('Work Item State toggle button component', () => {
expect(findStateToggleButton().text()).toBe(buttonText);
},
);
+
+ it.each`
+ workItemState | workItemType | buttonText
+ ${STATE_OPEN} | ${'Task'} | ${'Comment & close task'}
+ ${STATE_CLOSED} | ${'Task'} | ${'Comment & reopen task'}
+ ${STATE_OPEN} | ${'Objective'} | ${'Comment & close objective'}
+ ${STATE_CLOSED} | ${'Objective'} | ${'Comment & reopen objective'}
+ ${STATE_OPEN} | ${'Key result'} | ${'Comment & close key result'}
+ ${STATE_CLOSED} | ${'Key result'} | ${'Comment & reopen key result'}
+ `(
+ 'is "$buttonText" when "$workItemType" state is "$workItemState" and hasComment is true',
+ ({ workItemState, workItemType, buttonText }) => {
+ createComponent({ workItemState, workItemType, hasComment: true });
+
+ expect(findStateToggleButton().text()).toBe(buttonText);
+ },
+ );
});
describe('when updating the state', () => {
@@ -92,6 +111,15 @@ describe('Work Item State toggle button component', () => {
});
});
+ it('emits `submit-comment` when hasComment is true', async () => {
+ createComponent({ hasComment: true });
+
+ findStateToggleButton().vm.$emit('click');
+ await waitForPromises();
+
+ expect(wrapper.emitted('submit-comment')).toBeDefined();
+ });
+
it('emits an error message when the mutation was unsuccessful', async () => {
createComponent({ mutationHandler: jest.fn().mockRejectedValue('Error!') });