blob: 5d96fe276763e991d5b9cba5a758e90f234bf85a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import { formatDate } from '~/lib/utils/datetime_utility';
import RichTimestampTooltip from '~/vue_shared/components/rich_timestamp_tooltip.vue';
describe('RichTimestampTooltip', () => {
const currentDate = new Date();
const mockRawTimestamp = currentDate.toISOString();
const mockTimestamp = formatDate(currentDate);
let wrapper;
const createComponent = ({
target = 'some-element',
rawTimestamp = mockRawTimestamp,
timestampTypeText = 'Created',
} = {}) => {
wrapper = shallowMountExtended(RichTimestampTooltip, {
propsData: {
target,
rawTimestamp,
timestampTypeText,
},
});
};
beforeEach(() => {
createComponent();
});
afterEach(() => {
wrapper.destroy();
});
it('renders the tooltip text header', () => {
expect(wrapper.findByTestId('header-text').text()).toBe('Created just now');
});
it('renders the tooltip text body', () => {
expect(wrapper.findByTestId('body-text').text()).toBe(mockTimestamp);
});
});
|