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

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

55 lines
1.4 KiB
JavaScript
Raw Normal View History

2022-04-04 11:22:00 +05:30
import { GlAvatar } from '@gitlab/ui';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import RunnerAssignedItem from '~/runner/components/runner_assigned_item.vue';
2022-06-21 17:19:12 +05:30
import { AVATAR_SHAPE_OPTION_RECT } from '~/vue_shared/constants';
2022-04-04 11:22:00 +05:30
const mockHref = '/group/project';
const mockName = 'Project';
const mockFullName = 'Group / Project';
const mockAvatarUrl = '/avatar.png';
describe('RunnerAssignedItem', () => {
let wrapper;
const findAvatar = () => wrapper.findByTestId('item-avatar');
const createComponent = ({ props = {} } = {}) => {
wrapper = shallowMountExtended(RunnerAssignedItem, {
propsData: {
href: mockHref,
name: mockName,
fullName: mockFullName,
avatarUrl: mockAvatarUrl,
...props,
},
});
};
beforeEach(() => {
createComponent();
});
afterEach(() => {
wrapper.destroy();
});
it('Shows an avatar', () => {
const avatar = findAvatar();
expect(avatar.attributes('href')).toBe(mockHref);
expect(avatar.findComponent(GlAvatar).props()).toMatchObject({
alt: mockName,
entityName: mockName,
src: mockAvatarUrl,
2022-06-21 17:19:12 +05:30
shape: AVATAR_SHAPE_OPTION_RECT,
2022-04-04 11:22:00 +05:30
size: 48,
});
});
it('Shows an item link', () => {
const groupFullName = wrapper.findByText(mockFullName);
expect(groupFullName.attributes('href')).toBe(mockHref);
});
});