debian-mirror-gitlab/spec/frontend/members/components/table/created_at_spec.js

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

62 lines
1.6 KiB
JavaScript
Raw Normal View History

2021-01-03 14:25:43 +05:30
import { within } from '@testing-library/dom';
2021-03-11 19:13:27 +05:30
import { mount, createWrapper } from '@vue/test-utils';
2021-01-03 14:25:43 +05:30
import { useFakeDate } from 'helpers/fake_date';
2021-02-22 17:27:13 +05:30
import CreatedAt from '~/members/components/table/created_at.vue';
2021-01-03 14:25:43 +05:30
import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
describe('CreatedAt', () => {
// March 15th, 2020
useFakeDate(2020, 2, 15);
const date = '2020-03-01T00:00:00.000';
const dateTimeAgo = '2 weeks ago';
let wrapper;
2021-03-08 18:12:59 +05:30
const createComponent = (propsData) => {
2021-01-03 14:25:43 +05:30
wrapper = mount(CreatedAt, {
propsData: {
date,
...propsData,
},
});
};
const getByText = (text, options) =>
createWrapper(within(wrapper.element).getByText(text, options));
afterEach(() => {
wrapper.destroy();
});
describe('created at text', () => {
beforeEach(() => {
createComponent();
});
it('displays created at text', () => {
expect(getByText(dateTimeAgo).exists()).toBe(true);
});
it('uses `TimeAgoTooltip` component to display tooltip', () => {
2022-08-27 11:52:29 +05:30
expect(wrapper.findComponent(TimeAgoTooltip).exists()).toBe(true);
2021-01-03 14:25:43 +05:30
});
});
describe('when `createdBy` prop is provided', () => {
it('displays a link to the user that created the member', () => {
createComponent({
createdBy: {
name: 'Administrator',
webUrl: 'https://gitlab.com/root',
},
});
const link = getByText('Administrator');
expect(link.exists()).toBe(true);
expect(link.attributes('href')).toBe('https://gitlab.com/root');
});
});
});