debian-mirror-gitlab/spec/frontend/vue_shared/components/confidentiality_badge_spec.js

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

46 lines
1.5 KiB
JavaScript
Raw Normal View History

2022-07-16 23:28:13 +05:30
import { GlBadge } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
2023-05-27 22:25:52 +05:30
import { TYPE_ISSUE, TYPE_EPIC, WORKSPACE_GROUP, WORKSPACE_PROJECT } from '~/issues/constants';
2022-07-16 23:28:13 +05:30
import ConfidentialityBadge from '~/vue_shared/components/confidentiality_badge.vue';
2023-05-27 22:25:52 +05:30
const createComponent = ({ workspaceType = WORKSPACE_PROJECT, issuableType = TYPE_ISSUE } = {}) =>
2022-07-16 23:28:13 +05:30
shallowMount(ConfidentialityBadge, {
propsData: {
workspaceType,
issuableType,
},
});
describe('ConfidentialityBadge', () => {
let wrapper;
beforeEach(() => {
wrapper = createComponent();
});
it.each`
2023-05-27 22:25:52 +05:30
workspaceType | issuableType | expectedTooltip
${WORKSPACE_PROJECT} | ${TYPE_ISSUE} | ${'Only project members with at least the Reporter role, the author, and assignees can view or be notified about this issue.'}
${WORKSPACE_GROUP} | ${TYPE_EPIC} | ${'Only group members with at least the Reporter role can view or be notified about this epic.'}
2022-07-16 23:28:13 +05:30
`(
'should render gl-badge with correct tooltip when workspaceType is $workspaceType and issuableType is $issuableType',
({ workspaceType, issuableType, expectedTooltip }) => {
wrapper = createComponent({
workspaceType,
issuableType,
});
const badgeEl = wrapper.findComponent(GlBadge);
expect(badgeEl.props()).toMatchObject({
icon: 'eye-slash',
variant: 'warning',
});
expect(badgeEl.attributes('title')).toBe(expectedTooltip);
expect(badgeEl.text()).toBe('Confidential');
},
);
});