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

publish_button_spec.js « components « batch_comments « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9a782ec09b697dc30392f14e428e1588c0a8ad51 (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
35
36
37
38
import Vue, { nextTick } from 'vue';
import { mountComponentWithStore } from 'helpers/vue_mount_component_helper';
import PublishButton from '~/batch_comments/components/publish_button.vue';
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('sets loading when isPublishing is true', async () => {
    vm.$store.state.batchComments.isPublishing = true;

    await nextTick();
    expect(vm.$el.getAttribute('disabled')).toBe('disabled');
  });
});