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/batch_comments/components/submit_dropdown_spec.js')
-rw-r--r--spec/frontend/batch_comments/components/submit_dropdown_spec.js69
1 files changed, 69 insertions, 0 deletions
diff --git a/spec/frontend/batch_comments/components/submit_dropdown_spec.js b/spec/frontend/batch_comments/components/submit_dropdown_spec.js
new file mode 100644
index 00000000000..4f5ff797230
--- /dev/null
+++ b/spec/frontend/batch_comments/components/submit_dropdown_spec.js
@@ -0,0 +1,69 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import { mountExtended } from 'helpers/vue_test_utils_helper';
+import SubmitDropdown from '~/batch_comments/components/submit_dropdown.vue';
+
+Vue.use(Vuex);
+
+let wrapper;
+let publishReview;
+
+function factory() {
+ publishReview = jest.fn();
+
+ const store = new Vuex.Store({
+ getters: {
+ getNotesData: () => ({
+ markdownDocsPath: '/markdown/docs',
+ quickActionsDocsPath: '/quickactions/docs',
+ }),
+ getNoteableData: () => ({ id: 1, preview_note_path: '/preview' }),
+ noteableType: () => 'merge_request',
+ },
+ modules: {
+ batchComments: {
+ namespaced: true,
+ actions: {
+ publishReview,
+ },
+ },
+ },
+ });
+ wrapper = mountExtended(SubmitDropdown, {
+ store,
+ });
+}
+
+const findCommentTextarea = () => wrapper.findByTestId('comment-textarea');
+const findSubmitButton = () => wrapper.findByTestId('submit-review-button');
+const findForm = () => wrapper.findByTestId('submit-gl-form');
+
+describe('Batch comments submit dropdown', () => {
+ afterEach(() => {
+ wrapper.destroy();
+ });
+
+ it('calls publishReview with note data', async () => {
+ factory();
+
+ findCommentTextarea().setValue('Hello world');
+
+ await findForm().vm.$emit('submit', { preventDefault: jest.fn() });
+
+ expect(publishReview).toHaveBeenCalledWith(expect.anything(), {
+ noteable_type: 'merge_request',
+ noteable_id: 1,
+ note: 'Hello world',
+ });
+ });
+
+ it('sets submit dropdown to loading', async () => {
+ factory();
+
+ findCommentTextarea().setValue('Hello world');
+
+ await findForm().vm.$emit('submit', { preventDefault: jest.fn() });
+
+ expect(findSubmitButton().props('loading')).toBe(true);
+ });
+});