summaryrefslogtreecommitdiff
path: root/spec/frontend/runner/components/runner_type_badge_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/runner/components/runner_type_badge_spec.js')
-rw-r--r--spec/frontend/runner/components/runner_type_badge_spec.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/frontend/runner/components/runner_type_badge_spec.js b/spec/frontend/runner/components/runner_type_badge_spec.js
new file mode 100644
index 00000000000..8e52d3398bd
--- /dev/null
+++ b/spec/frontend/runner/components/runner_type_badge_spec.js
@@ -0,0 +1,40 @@
+import { GlBadge } from '@gitlab/ui';
+import { shallowMount } from '@vue/test-utils';
+import RunnerTypeBadge from '~/runner/components/runner_type_badge.vue';
+import { INSTANCE_TYPE, GROUP_TYPE, PROJECT_TYPE } from '~/runner/constants';
+
+describe('RunnerTypeBadge', () => {
+ let wrapper;
+
+ const findBadge = () => wrapper.findComponent(GlBadge);
+
+ const createComponent = ({ props = {} } = {}) => {
+ wrapper = shallowMount(RunnerTypeBadge, {
+ propsData: {
+ ...props,
+ },
+ });
+ };
+
+ afterEach(() => {
+ wrapper.destroy();
+ });
+
+ it.each`
+ type | text | variant
+ ${INSTANCE_TYPE} | ${'shared'} | ${'success'}
+ ${GROUP_TYPE} | ${'group'} | ${'success'}
+ ${PROJECT_TYPE} | ${'specific'} | ${'info'}
+ `('displays $type runner with as "$text" with a $variant variant ', ({ type, text, variant }) => {
+ createComponent({ props: { type } });
+
+ expect(findBadge().text()).toBe(text);
+ expect(findBadge().props('variant')).toBe(variant);
+ });
+
+ it('does not display a badge when type is unknown', () => {
+ createComponent({ props: { type: 'AN_UNKNOWN_VALUE' } });
+
+ expect(findBadge().exists()).toBe(false);
+ });
+});