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

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

62 lines
1.7 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
2022-05-07 20:08:51 +05:30
// hardcode uniqueId for determinism
jest.mock('lodash/uniqueId', () => (x) => `${x}77`);
const EXPECTED_COPY_PRE_ID = 'enable-review-app-copy-string-77';
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
2022-05-07 20:08:51 +05:30
const findCopyString = () => wrapper.find(`#${EXPECTED_COPY_PRE_ID}`);
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', () => {
expect(findCopyString().text()).toContain('- main');
2020-03-13 15:44:24 +05:30
});
it('renders the copyToClipboard button', () => {
2022-05-07 20:08:51 +05:30
expect(wrapper.findComponent(ModalCopyButton).props()).toMatchObject({
modalId: 'fake-id',
target: `#${EXPECTED_COPY_PRE_ID}`,
title: 'Copy snippet text',
});
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
});
});