summaryrefslogtreecommitdiff
path: root/spec/frontend/batch_comments/components/publish_button_spec.js
blob: 5e3fa3e9446c821c4561784d3a5f74729f14ec43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { nextTick } from 'vue';
import { mount } from '@vue/test-utils';
import PublishButton from '~/batch_comments/components/publish_button.vue';
import { createStore } from '~/batch_comments/stores';

describe('Batch comments publish button component', () => {
  let wrapper;
  let store;

  beforeEach(() => {
    store = createStore();

    wrapper = mount(PublishButton, { store, propsData: { shouldPublish: true } });

    jest.spyOn(store, 'dispatch').mockImplementation();
  });

  afterEach(() => {
    wrapper.destroy();
  });

  it('dispatches publishReview on click', async () => {
    await wrapper.trigger('click');

    expect(store.dispatch).toHaveBeenCalledWith('batchComments/publishReview', undefined);
  });

  it('sets loading when isPublishing is true', async () => {
    store.state.batchComments.isPublishing = true;

    await nextTick();
    expect(wrapper.attributes('disabled')).toBe('disabled');
  });
});