38 lines
1.0 KiB
JavaScript
38 lines
1.0 KiB
JavaScript
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();
|
|
});
|
|
|
|
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);
|
|
});
|
|
});
|