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.

49 lines
1.2 KiB
JavaScript
Raw Normal View History

2023-03-17 16:20:25 +05:30
import { mountExtended } from 'helpers/vue_test_utils_helper';
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
describe('CreatedAt', () => {
// March 15th, 2020
useFakeDate(2020, 2, 15);
const date = '2020-03-01T00:00:00.000';
2023-03-17 16:20:25 +05:30
const formattedDate = 'Mar 01, 2020';
2021-01-03 14:25:43 +05:30
let wrapper;
2021-03-08 18:12:59 +05:30
const createComponent = (propsData) => {
2023-03-17 16:20:25 +05:30
wrapper = mountExtended(CreatedAt, {
2021-01-03 14:25:43 +05:30
propsData: {
date,
...propsData,
},
});
};
describe('created at text', () => {
beforeEach(() => {
createComponent();
});
it('displays created at text', () => {
2023-03-17 16:20:25 +05:30
expect(wrapper.findByText(formattedDate).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',
},
});
2023-03-17 16:20:25 +05:30
const link = wrapper.findByRole('link', { name: 'Administrator' });
2021-01-03 14:25:43 +05:30
expect(link.exists()).toBe(true);
expect(link.attributes('href')).toBe('https://gitlab.com/root');
});
});
});