debian-mirror-gitlab/spec/frontend/jobs/bridge/components/empty_state_spec.js

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

59 lines
1.6 KiB
JavaScript
Raw Normal View History

2022-01-26 12:08:38 +05:30
import { GlButton } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import BridgeEmptyState from '~/jobs/bridge/components/empty_state.vue';
import { MOCK_EMPTY_ILLUSTRATION_PATH, MOCK_PATH_TO_DOWNSTREAM } from '../mock_data';
describe('Bridge Empty State', () => {
let wrapper;
2022-03-02 08:16:31 +05:30
const createComponent = ({ downstreamPipelinePath }) => {
2022-01-26 12:08:38 +05:30
wrapper = shallowMount(BridgeEmptyState, {
provide: {
emptyStateIllustrationPath: MOCK_EMPTY_ILLUSTRATION_PATH,
},
propsData: {
2022-03-02 08:16:31 +05:30
downstreamPipelinePath,
2022-01-26 12:08:38 +05:30
},
});
};
const findSvg = () => wrapper.find('img');
const findTitle = () => wrapper.find('h1');
const findLinkBtn = () => wrapper.findComponent(GlButton);
afterEach(() => {
wrapper.destroy();
});
describe('template', () => {
beforeEach(() => {
2022-03-02 08:16:31 +05:30
createComponent({ downstreamPipelinePath: MOCK_PATH_TO_DOWNSTREAM });
2022-01-26 12:08:38 +05:30
});
it('renders illustration', () => {
expect(findSvg().exists()).toBe(true);
});
it('renders title', () => {
expect(findTitle().exists()).toBe(true);
expect(findTitle().text()).toBe(wrapper.vm.$options.i18n.title);
});
it('renders CTA button', () => {
expect(findLinkBtn().exists()).toBe(true);
expect(findLinkBtn().text()).toBe(wrapper.vm.$options.i18n.linkBtnText);
expect(findLinkBtn().attributes('href')).toBe(MOCK_PATH_TO_DOWNSTREAM);
});
});
describe('without downstream pipeline', () => {
beforeEach(() => {
createComponent({ downstreamPipelinePath: undefined });
});
it('does not render CTA button', () => {
expect(findLinkBtn().exists()).toBe(false);
});
});
});