debian-mirror-gitlab/spec/frontend/runner/components/runner_paused_badge_spec.js

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

47 lines
1.2 KiB
JavaScript
Raw Normal View History

2021-11-18 22:05:49 +05:30
import { GlBadge } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
2021-12-11 22:18:48 +05:30
import RunnerStatePausedBadge from '~/runner/components/runner_paused_badge.vue';
2021-11-18 22:05:49 +05:30
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
2022-10-11 01:57:18 +05:30
import { I18N_PAUSED } from '~/runner/constants';
2021-11-18 22:05:49 +05:30
describe('RunnerTypeBadge', () => {
let wrapper;
const findBadge = () => wrapper.findComponent(GlBadge);
const getTooltip = () => getBinding(findBadge().element, 'gl-tooltip');
const createComponent = ({ props = {} } = {}) => {
wrapper = shallowMount(RunnerStatePausedBadge, {
propsData: {
...props,
},
directives: {
GlTooltip: createMockDirective(),
},
});
};
beforeEach(() => {
createComponent();
});
afterEach(() => {
wrapper.destroy();
});
it('renders paused state', () => {
2022-10-11 01:57:18 +05:30
expect(wrapper.text()).toBe(I18N_PAUSED);
expect(findBadge().props('variant')).toBe('warning');
2021-11-18 22:05:49 +05:30
});
it('renders tooltip', () => {
expect(getTooltip().value).toBeDefined();
});
it('passes arbitrary attributes to the badge', () => {
createComponent({ props: { size: 'sm' } });
expect(findBadge().props('size')).toBe('sm');
});
});