2020-02-10 13:09:00 -05:00
|
|
|
import { GlIcon, GlLink } from '@gitlab/ui';
|
2021-02-14 13:09:20 -05:00
|
|
|
import { shallowMount } from '@vue/test-utils';
|
2020-02-10 13:09:00 -05:00
|
|
|
import { TEST_HOST } from 'helpers/test_constants';
|
|
|
|
import IdeStatusMr from '~/ide/components/ide_status_mr.vue';
|
|
|
|
|
|
|
|
const TEST_TEXT = '!9001';
|
|
|
|
const TEST_URL = `${TEST_HOST}merge-requests/9001`;
|
|
|
|
|
|
|
|
describe('ide/components/ide_status_mr', () => {
|
|
|
|
let wrapper;
|
|
|
|
|
2020-12-23 16:10:24 -05:00
|
|
|
const createComponent = (props) => {
|
2020-02-10 13:09:00 -05:00
|
|
|
wrapper = shallowMount(IdeStatusMr, {
|
|
|
|
propsData: props,
|
|
|
|
});
|
|
|
|
};
|
2022-08-15 05:11:06 -04:00
|
|
|
const findIcon = () => wrapper.findComponent(GlIcon);
|
|
|
|
const findLink = () => wrapper.findComponent(GlLink);
|
2020-02-10 13:09:00 -05:00
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when mounted', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
createComponent({
|
|
|
|
text: TEST_TEXT,
|
|
|
|
url: TEST_URL,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders icon', () => {
|
|
|
|
const icon = findIcon();
|
|
|
|
|
|
|
|
expect(icon.exists()).toBe(true);
|
|
|
|
expect(icon.props()).toEqual(
|
|
|
|
expect.objectContaining({
|
|
|
|
name: 'merge-request',
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders link', () => {
|
|
|
|
const link = findLink();
|
|
|
|
|
|
|
|
expect(link.exists()).toBe(true);
|
|
|
|
expect(link.attributes()).toEqual(
|
|
|
|
expect.objectContaining({
|
|
|
|
href: TEST_URL,
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
expect(link.text()).toEqual(TEST_TEXT);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders text', () => {
|
|
|
|
expect(wrapper.text()).toBe(`Merge request ${TEST_TEXT}`);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|