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,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
it.each`
|
2021-10-27 15:23:28 +05:30
|
|
|
date | dateFormat | output
|
2023-03-17 16:20:25 +05:30
|
|
|
${mockDate} | ${undefined} | ${'Nov 13, 2020'}
|
2021-10-27 15:23:28 +05:30
|
|
|
${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);
|
|
|
|
});
|
|
|
|
});
|