debian-mirror-gitlab/spec/frontend/environments/enable_review_app_modal_spec.js

52 lines
1.4 KiB
JavaScript
Raw Normal View History

2021-01-03 14:25:43 +05:30
import { shallowMount } from '@vue/test-utils';
2022-01-26 12:08:38 +05:30
import { GlModal } from '@gitlab/ui';
2021-04-29 21:17:54 +05:30
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
2021-01-03 14:25:43 +05:30
import EnableReviewAppButton from '~/environments/components/enable_review_app_modal.vue';
2021-03-11 19:13:27 +05:30
import ModalCopyButton from '~/vue_shared/components/modal_copy_button.vue';
2020-03-13 15:44:24 +05:30
describe('Enable Review App Button', () => {
let wrapper;
2022-01-26 12:08:38 +05:30
let modal;
2020-03-13 15:44:24 +05:30
afterEach(() => {
wrapper.destroy();
});
describe('renders the modal', () => {
beforeEach(() => {
2021-04-29 21:17:54 +05:30
wrapper = extendedWrapper(
shallowMount(EnableReviewAppButton, {
propsData: {
modalId: 'fake-id',
2022-01-26 12:08:38 +05:30
visible: true,
2021-04-29 21:17:54 +05:30
},
provide: {
defaultBranchName: 'main',
},
}),
);
2022-01-26 12:08:38 +05:30
modal = wrapper.findComponent(GlModal);
2021-04-29 21:17:54 +05:30
});
it('renders the defaultBranchName copy', () => {
const findCopyString = () => wrapper.findByTestId('enable-review-app-copy-string');
expect(findCopyString().text()).toContain('- main');
2020-03-13 15:44:24 +05:30
});
it('renders the copyToClipboard button', () => {
2021-04-29 21:17:54 +05:30
expect(wrapper.findComponent(ModalCopyButton).exists()).toBe(true);
2020-03-13 15:44:24 +05:30
});
2022-01-26 12:08:38 +05:30
it('emits change events from the modal up', () => {
modal.vm.$emit('change', false);
expect(wrapper.emitted('change')).toEqual([[false]]);
});
it('passes visible to the modal', () => {
expect(modal.props('visible')).toBe(true);
});
2020-03-13 15:44:24 +05:30
});
});