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.

67 lines
2 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';
2022-11-25 23:54:43 +05:30
import EnableReviewAppModal from '~/environments/components/enable_review_app_modal.vue';
import { REVIEW_APP_MODAL_I18N as i18n } from '~/environments/constants';
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';
2022-11-25 23:54:43 +05:30
describe('Enable Review App Modal', () => {
2020-03-13 15:44:24 +05:30
let wrapper;
2022-01-26 12:08:38 +05:30
let modal;
2020-03-13 15:44:24 +05:30
2022-11-25 23:54:43 +05:30
const findInstructions = () => wrapper.findAll('ol li');
const findInstructionAt = (i) => wrapper.findAll('ol li').at(i);
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(
2022-11-25 23:54:43 +05:30
shallowMount(EnableReviewAppModal, {
2021-04-29 21:17:54 +05:30
propsData: {
modalId: 'fake-id',
2022-01-26 12:08:38 +05:30
visible: true,
2021-04-29 21:17:54 +05:30
},
}),
);
2022-01-26 12:08:38 +05:30
modal = wrapper.findComponent(GlModal);
2021-04-29 21:17:54 +05:30
});
2022-11-25 23:54:43 +05:30
it('displays instructions', () => {
expect(findInstructions().length).toBe(7);
expect(findInstructionAt(0).text()).toContain(i18n.instructions.step1);
});
it('renders the snippet to copy', () => {
expect(findCopyString().text()).toBe(wrapper.vm.modalInfoCopyStr);
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}`,
2022-11-25 23:54:43 +05:30
title: i18n.copyToClipboardText,
2022-05-07 20:08:51 +05:30
});
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
});
});