debian-mirror-gitlab/spec/frontend/boards/components/new_board_button_spec.js

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

70 lines
1.9 KiB
JavaScript
Raw Normal View History

2021-12-11 22:18:48 +05:30
import { mount } from '@vue/test-utils';
import { GlButton } from '@gitlab/ui';
import NewBoardButton from '~/boards/components/new_board_button.vue';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import { stubExperiments } from 'helpers/experimentation_helper';
import eventHub from '~/boards/eventhub';
const FEATURE = 'prominent_create_board_btn';
describe('NewBoardButton', () => {
let wrapper;
const createComponent = (args = {}) =>
extendedWrapper(
mount(NewBoardButton, {
provide: {
canAdminBoard: true,
multipleIssueBoardsAvailable: true,
...args,
},
}),
);
describe('control variant', () => {
beforeAll(() => {
stubExperiments({ [FEATURE]: 'control' });
});
it('renders nothing', () => {
wrapper = createComponent();
expect(wrapper.text()).toBe('');
});
});
describe('candidate variant', () => {
beforeAll(() => {
stubExperiments({ [FEATURE]: 'candidate' });
});
it('renders New board button when `candidate` variant', () => {
wrapper = createComponent();
expect(wrapper.text()).toBe('New board');
});
it('renders nothing when `canAdminBoard` is `false`', () => {
wrapper = createComponent({ canAdminBoard: false });
2022-08-27 11:52:29 +05:30
expect(wrapper.findComponent(GlButton).exists()).toBe(false);
2021-12-11 22:18:48 +05:30
});
it('renders nothing when `multipleIssueBoardsAvailable` is `false`', () => {
wrapper = createComponent({ multipleIssueBoardsAvailable: false });
2022-08-27 11:52:29 +05:30
expect(wrapper.findComponent(GlButton).exists()).toBe(false);
2021-12-11 22:18:48 +05:30
});
it('emits `showBoardModal` when button is clicked', () => {
jest.spyOn(eventHub, '$emit').mockImplementation();
wrapper = createComponent();
2022-08-27 11:52:29 +05:30
wrapper.findComponent(GlButton).vm.$emit('click', { preventDefault: () => {} });
2021-12-11 22:18:48 +05:30
expect(eventHub.$emit).toHaveBeenCalledWith('showBoardModal', 'new');
});
});
});