debian-mirror-gitlab/spec/frontend/batch_comments/components/publish_button_spec.js

39 lines
1 KiB
JavaScript
Raw Normal View History

2022-04-04 11:22:00 +05:30
import Vue, { nextTick } from 'vue';
2020-06-23 00:09:42 +05:30
import { mountComponentWithStore } from 'helpers/vue_mount_component_helper';
2020-10-24 23:57:45 +05:30
import PublishButton from '~/batch_comments/components/publish_button.vue';
2020-06-23 00:09:42 +05:30
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);
});
2022-04-04 11:22:00 +05:30
it('sets loading when isPublishing is true', async () => {
2020-06-23 00:09:42 +05:30
vm.$store.state.batchComments.isPublishing = true;
2022-04-04 11:22:00 +05:30
await nextTick();
expect(vm.$el.getAttribute('disabled')).toBe('disabled');
2020-06-23 00:09:42 +05:30
});
});