debian-mirror-gitlab/spec/frontend/admin/users/components/user_date_spec.js

39 lines
1 KiB
JavaScript
Raw Normal View History

2021-03-11 19:13:27 +05:30
import { shallowMount } from '@vue/test-utils';
2021-04-29 21:17:54 +05:30
import UserDate from '~/vue_shared/components/user_date.vue';
2021-10-27 15:23:28 +05:30
import { ISO_SHORT_FORMAT } from '~/vue_shared/constants';
2021-03-11 19:13:27 +05:30
import { users } from '../mock_data';
const mockDate = users[0].createdAt;
describe('FormatDate component', () => {
let wrapper;
const initComponent = (props = {}) => {
wrapper = shallowMount(UserDate, {
propsData: {
...props,
},
});
};
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
it.each`
2021-10-27 15:23:28 +05:30
date | dateFormat | output
${mockDate} | ${undefined} | ${'13 Nov, 2020'}
${null} | ${undefined} | ${'Never'}
${undefined} | ${undefined} | ${'Never'}
${mockDate} | ${ISO_SHORT_FORMAT} | ${'2020-11-13'}
${null} | ${ISO_SHORT_FORMAT} | ${'Never'}
${undefined} | ${ISO_SHORT_FORMAT} | ${'Never'}
`('renders $date as $output', ({ date, dateFormat, output }) => {
initComponent({ date, dateFormat });
2021-03-11 19:13:27 +05:30
expect(wrapper.text()).toBe(output);
});
});