forked from jupyterlab/jupyterlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
time.spec.ts
43 lines (30 loc) · 1014 Bytes
/
time.spec.ts
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
42
43
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
import {
expect
} from 'chai';
import {
Time
} from '@jupyterlab/coreutils';
describe('@jupyterlab/coreutils', () => {
describe('Time', () => {
describe('.formatHuman()', () => {
it('should convert a time to a human readable string', () => {
let date = new Date();
date.setSeconds(date.getSeconds() - 10);
let value = Time.formatHuman(date);
expect(value).to.equal('seconds ago');
date.setMinutes(date.getMinutes() - 3);
expect(Time.formatHuman(date.toISOString())).to.equal('3 minutes ago');
});
});
describe('.format()', () => {
it('should convert a timestring to a date format', () => {
expect(Time.format(new Date()).length).to.equal(16);
let date = new Date();
let value = Time.format(date.toISOString(), 'MM-DD');
expect(value.length).to.equal(5);
});
});
});
});