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

46 lines
1.1 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';
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', () => {
expect(wrapper.text()).toBe('paused');
expect(findBadge().props('variant')).toBe('danger');
});
it('renders tooltip', () => {
expect(getTooltip().value).toBeDefined();
});
it('passes arbitrary attributes to the badge', () => {
createComponent({ props: { size: 'sm' } });
expect(findBadge().props('size')).toBe('sm');
});
});