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

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

36 lines
1.2 KiB
JavaScript
Raw Normal View History

2020-10-24 23:57:45 +05:30
import { mount } from '@vue/test-utils';
2022-11-25 23:54:43 +05:30
import { s__, __ } from '~/locale';
2020-03-13 15:44:24 +05:30
import ExternalUrlComp from '~/environments/components/environment_external_url.vue';
2022-11-25 23:54:43 +05:30
import ModalCopyButton from '~/vue_shared/components/modal_copy_button.vue';
2020-03-13 15:44:24 +05:30
describe('External URL Component', () => {
let wrapper;
2022-11-25 23:54:43 +05:30
let externalUrl;
2020-03-13 15:44:24 +05:30
2022-11-25 23:54:43 +05:30
describe('with safe link', () => {
beforeEach(() => {
externalUrl = 'https://gitlab.com';
wrapper = mount(ExternalUrlComp, { propsData: { externalUrl } });
});
it('should link to the provided externalUrl prop', () => {
expect(wrapper.attributes('href')).toBe(externalUrl);
expect(wrapper.find('a').exists()).toBe(true);
});
2020-03-13 15:44:24 +05:30
});
2022-11-25 23:54:43 +05:30
describe('with unsafe link', () => {
beforeEach(() => {
externalUrl = 'postgres://gitlab';
wrapper = mount(ExternalUrlComp, { propsData: { externalUrl } });
});
it('should show a copy button instead', () => {
const button = wrapper.findComponent(ModalCopyButton);
expect(button.props('text')).toBe(externalUrl);
expect(button.text()).toBe(__('Copy URL'));
expect(button.props('title')).toBe(s__('Environments|Copy live environment URL'));
});
2020-03-13 15:44:24 +05:30
});
});