summaryrefslogtreecommitdiff
path: root/spec/frontend/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-25 12:08:48 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-25 12:08:48 +0000
commitf7dae0cdcb70ecb71c1d65f099e9d96b27a4548c (patch)
treee53baffa847c4fd37c8e335e4d93d603c75f9f02 /spec/frontend/lib
parentb98fa9ef3d5bead417ae2f325cb64637883264e9 (diff)
downloadgitlab-ce-f7dae0cdcb70ecb71c1d65f099e9d96b27a4548c.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/lib')
-rw-r--r--spec/frontend/lib/utils/datetime_utility_spec.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/frontend/lib/utils/datetime_utility_spec.js b/spec/frontend/lib/utils/datetime_utility_spec.js
index e584150ba70..27b88d78ff0 100644
--- a/spec/frontend/lib/utils/datetime_utility_spec.js
+++ b/spec/frontend/lib/utils/datetime_utility_spec.js
@@ -1,4 +1,6 @@
import { __, s__ } from '~/locale';
+import $ from 'jquery';
+import '~/commons/bootstrap';
import * as datetimeUtility from '~/lib/utils/datetime_utility';
describe('Date time utils', () => {
@@ -563,3 +565,23 @@ describe('approximateDuration', () => {
expect(datetimeUtility.approximateDuration(seconds)).toBe(approximation);
});
});
+
+describe('localTimeAgo', () => {
+ beforeEach(() => {
+ document.body.innerHTML = `<time title="some time" datetime="2020-02-18T22:22:32Z">1 hour ago</time>`;
+ });
+
+ it.each`
+ timeagoArg | title | dataOriginalTitle
+ ${false} | ${'some time'} | ${null}
+ ${true} | ${''} | ${'Feb 18, 2020 10:22pm GMT+0000'}
+ `('converts $seconds seconds to $approximation', ({ timeagoArg, title, dataOriginalTitle }) => {
+ const element = document.querySelector('time');
+ datetimeUtility.localTimeAgo($(element), timeagoArg);
+
+ jest.runAllTimers();
+
+ expect(element.getAttribute('data-original-title')).toBe(dataOriginalTitle);
+ expect(element.getAttribute('title')).toBe(title);
+ });
+});