summaryrefslogtreecommitdiff
path: root/spec/frontend/batch_comments/components/publish_button_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/batch_comments/components/publish_button_spec.js')
-rw-r--r--spec/frontend/batch_comments/components/publish_button_spec.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/spec/frontend/batch_comments/components/publish_button_spec.js b/spec/frontend/batch_comments/components/publish_button_spec.js
new file mode 100644
index 00000000000..97f3a1c8939
--- /dev/null
+++ b/spec/frontend/batch_comments/components/publish_button_spec.js
@@ -0,0 +1,52 @@
+import Vue from 'vue';
+import PublishButton from '~/batch_comments/components/publish_button.vue';
+import { mountComponentWithStore } from 'helpers/vue_mount_component_helper';
+import { createStore } from '~/batch_comments/stores';
+
+describe('Batch comments publish button component', () => {
+ let vm;
+ let Component;
+
+ beforeAll(() => {
+ Component = Vue.extend(PublishButton);
+ });
+
+ beforeEach(() => {
+ const store = createStore();
+
+ vm = mountComponentWithStore(Component, { store, props: { shouldPublish: true } });
+
+ jest.spyOn(vm.$store, 'dispatch').mockImplementation();
+ });
+
+ afterEach(() => {
+ vm.$destroy();
+ });
+
+ it('dispatches publishReview on click', () => {
+ vm.$el.click();
+
+ expect(vm.$store.dispatch).toHaveBeenCalledWith('batchComments/publishReview', undefined);
+ });
+
+ it('dispatches toggleReviewDropdown when shouldPublish is false on click', () => {
+ vm.shouldPublish = false;
+
+ vm.$el.click();
+
+ expect(vm.$store.dispatch).toHaveBeenCalledWith(
+ 'batchComments/toggleReviewDropdown',
+ undefined,
+ );
+ });
+
+ it('sets loading when isPublishing is true', done => {
+ vm.$store.state.batchComments.isPublishing = true;
+
+ vm.$nextTick(() => {
+ expect(vm.$el.getAttribute('disabled')).toBe('disabled');
+
+ done();
+ });
+ });
+});