summaryrefslogtreecommitdiff
path: root/spec/frontend/vue_shared/components/time_ago_tooltip_spec.js
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-08-20 18:42:06 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-08-20 18:42:06 +0000
commit6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch)
tree78be5963ec075d80116a932011d695dd33910b4e /spec/frontend/vue_shared/components/time_ago_tooltip_spec.js
parent1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff)
downloadgitlab-ce-6e4e1050d9dba2b7b2523fdd1768823ab85feef4.tar.gz
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'spec/frontend/vue_shared/components/time_ago_tooltip_spec.js')
-rw-r--r--spec/frontend/vue_shared/components/time_ago_tooltip_spec.js22
1 files changed, 18 insertions, 4 deletions
diff --git a/spec/frontend/vue_shared/components/time_ago_tooltip_spec.js b/spec/frontend/vue_shared/components/time_ago_tooltip_spec.js
index 46fcb92455b..691e19473c1 100644
--- a/spec/frontend/vue_shared/components/time_ago_tooltip_spec.js
+++ b/spec/frontend/vue_shared/components/time_ago_tooltip_spec.js
@@ -1,16 +1,19 @@
import { shallowMount } from '@vue/test-utils';
-import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
+
import { formatDate, getTimeago } from '~/lib/utils/datetime_utility';
+import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
describe('Time ago with tooltip component', () => {
let vm;
- const buildVm = (propsData = {}) => {
+ const buildVm = (propsData = {}, scopedSlots = {}) => {
vm = shallowMount(TimeAgoTooltip, {
propsData,
+ scopedSlots,
});
};
const timestamp = '2017-05-08T14:57:39.781Z';
+ const timeAgoTimestamp = getTimeago().format(timestamp);
afterEach(() => {
vm.destroy();
@@ -20,10 +23,9 @@ describe('Time ago with tooltip component', () => {
buildVm({
time: timestamp,
});
- const timeago = getTimeago();
expect(vm.attributes('title')).toEqual(formatDate(timestamp));
- expect(vm.text()).toEqual(timeago.format(timestamp));
+ expect(vm.text()).toEqual(timeAgoTimestamp);
});
it('should render provided html class', () => {
@@ -34,4 +36,16 @@ describe('Time ago with tooltip component', () => {
expect(vm.classes()).toContain('foo');
});
+
+ it('should render with the datetime attribute', () => {
+ buildVm({ time: timestamp });
+
+ expect(vm.attributes('datetime')).toEqual(timestamp);
+ });
+
+ it('should render provided scope content with the correct timeAgo string', () => {
+ buildVm({ time: timestamp }, { default: `<span>The time is {{ props.timeAgo }}</span>` });
+
+ expect(vm.text()).toEqual(`The time is ${timeAgoTimestamp}`);
+ });
});