]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/relative-date.pipe.spec.ts
import 15.2.0 Octopus source
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / pipes / relative-date.pipe.spec.ts
1 import * as moment from 'moment';
2
3 import { RelativeDatePipe } from './relative-date.pipe';
4
5 describe('RelativeDatePipe', () => {
6 const pipe = new RelativeDatePipe();
7
8 it('create an instance', () => {
9 expect(pipe).toBeTruthy();
10 });
11
12 it('transforms without value', () => {
13 expect(pipe.transform(undefined)).toBe('unknown');
14 });
15
16 it('transforms "in 7 days"', () => {
17 const value = moment()
18 .add(7, 'days')
19 .unix();
20 expect(pipe.transform(value)).toBe('in 7 days');
21 });
22
23 it('transforms "7 days ago"', () => {
24 const value = moment()
25 .subtract(7, 'days')
26 .unix();
27 expect(pipe.transform(value)).toBe('7 days ago');
28 });
29 });