debian-mirror-gitlab/spec/frontend/notes/components/discussion_resolve_button_spec.js

74 lines
1.5 KiB
JavaScript
Raw Normal View History

2020-11-24 15:15:51 +05:30
import { GlButton } from '@gitlab/ui';
2021-03-11 19:13:27 +05:30
import { shallowMount } from '@vue/test-utils';
2022-04-04 11:22:00 +05:30
import { nextTick } from 'vue';
2020-01-01 13:55:28 +05:30
import resolveDiscussionButton from '~/notes/components/discussion_resolve_button.vue';
2019-03-02 22:35:43 +05:30
const buttonTitle = 'Resolve discussion';
describe('resolveDiscussionButton', () => {
let wrapper;
2021-03-08 18:12:59 +05:30
const factory = (options) => {
2019-03-02 22:35:43 +05:30
wrapper = shallowMount(resolveDiscussionButton, {
...options,
});
};
beforeEach(() => {
factory({
propsData: {
isResolving: false,
buttonTitle,
},
});
});
afterEach(() => {
wrapper.destroy();
});
2022-04-04 11:22:00 +05:30
it('should emit a onClick event on button click', async () => {
2020-11-24 15:15:51 +05:30
const button = wrapper.find(GlButton);
2019-03-02 22:35:43 +05:30
2020-11-24 15:15:51 +05:30
button.vm.$emit('click');
2019-03-02 22:35:43 +05:30
2022-04-04 11:22:00 +05:30
await nextTick();
expect(wrapper.emitted()).toEqual({
onClick: [[]],
2019-03-02 22:35:43 +05:30
});
});
it('should contain the provided button title', () => {
2020-11-24 15:15:51 +05:30
const button = wrapper.find(GlButton);
2019-03-02 22:35:43 +05:30
expect(button.text()).toContain(buttonTitle);
});
it('should show a loading spinner while resolving', () => {
factory({
propsData: {
isResolving: true,
buttonTitle,
},
});
2020-11-24 15:15:51 +05:30
const button = wrapper.find(GlButton);
2019-03-02 22:35:43 +05:30
2020-11-24 15:15:51 +05:30
expect(button.props('loading')).toEqual(true);
2019-03-02 22:35:43 +05:30
});
2022-04-04 11:22:00 +05:30
it('should only show a loading spinner while resolving', async () => {
2019-03-02 22:35:43 +05:30
factory({
propsData: {
isResolving: false,
buttonTitle,
},
});
2020-11-24 15:15:51 +05:30
const button = wrapper.find(GlButton);
2019-03-02 22:35:43 +05:30
2022-04-04 11:22:00 +05:30
await nextTick();
expect(button.props('loading')).toEqual(false);
2019-03-02 22:35:43 +05:30
});
});