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

74 lines
1.5 KiB
JavaScript
Raw Normal View History

2020-03-09 13:42:32 +05:30
import { shallowMount } from '@vue/test-utils';
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;
const factory = options => {
wrapper = shallowMount(resolveDiscussionButton, {
...options,
});
};
beforeEach(() => {
factory({
propsData: {
isResolving: false,
buttonTitle,
},
});
});
afterEach(() => {
wrapper.destroy();
});
it('should emit a onClick event on button click', () => {
const button = wrapper.find({ ref: 'button' });
button.trigger('click');
2020-03-09 13:42:32 +05:30
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted()).toEqual({
onClick: [[]],
});
2019-03-02 22:35:43 +05:30
});
});
it('should contain the provided button title', () => {
const button = wrapper.find({ ref: 'button' });
expect(button.text()).toContain(buttonTitle);
});
it('should show a loading spinner while resolving', () => {
factory({
propsData: {
isResolving: true,
buttonTitle,
},
});
const button = wrapper.find({ ref: 'isResolvingIcon' });
expect(button.exists()).toEqual(true);
});
it('should only show a loading spinner while resolving', () => {
factory({
propsData: {
isResolving: false,
buttonTitle,
},
});
const button = wrapper.find({ ref: 'isResolvingIcon' });
2020-03-09 13:42:32 +05:30
wrapper.vm.$nextTick(() => {
2019-03-02 22:35:43 +05:30
expect(button.exists()).toEqual(false);
});
});
});