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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

35 lines
937 B
JavaScript
Raw Normal View History

2022-11-25 23:54:43 +05:30
import { nextTick } from 'vue';
import { mount } from '@vue/test-utils';
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', () => {
2022-11-25 23:54:43 +05:30
let wrapper;
let store;
2020-06-23 00:09:42 +05:30
beforeEach(() => {
2022-11-25 23:54:43 +05:30
store = createStore();
2020-06-23 00:09:42 +05:30
2022-11-25 23:54:43 +05:30
wrapper = mount(PublishButton, { store, propsData: { shouldPublish: true } });
2020-06-23 00:09:42 +05:30
2022-11-25 23:54:43 +05:30
jest.spyOn(store, 'dispatch').mockImplementation();
2020-06-23 00:09:42 +05:30
});
afterEach(() => {
2022-11-25 23:54:43 +05:30
wrapper.destroy();
2020-06-23 00:09:42 +05:30
});
2022-11-25 23:54:43 +05:30
it('dispatches publishReview on click', async () => {
await wrapper.trigger('click');
2020-06-23 00:09:42 +05:30
2022-11-25 23:54:43 +05:30
expect(store.dispatch).toHaveBeenCalledWith('batchComments/publishReview', undefined);
2020-06-23 00:09:42 +05:30
});
2022-04-04 11:22:00 +05:30
it('sets loading when isPublishing is true', async () => {
2022-11-25 23:54:43 +05:30
store.state.batchComments.isPublishing = true;
2020-06-23 00:09:42 +05:30
2022-04-04 11:22:00 +05:30
await nextTick();
2022-11-25 23:54:43 +05:30
expect(wrapper.attributes('disabled')).toBe('disabled');
2020-06-23 00:09:42 +05:30
});
});