debian-mirror-gitlab/spec/frontend/runner/components/runner_assigned_item_spec.js
2022-06-21 17:19:12 +05:30

54 lines
1.4 KiB
JavaScript

import { GlAvatar } from '@gitlab/ui';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import RunnerAssignedItem from '~/runner/components/runner_assigned_item.vue';
import { AVATAR_SHAPE_OPTION_RECT } from '~/vue_shared/constants';
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,
shape: AVATAR_SHAPE_OPTION_RECT,
size: 48,
});
});
it('Shows an item link', () => {
const groupFullName = wrapper.findByText(mockFullName);
expect(groupFullName.attributes('href')).toBe(mockHref);
});
});