Skip to content

Commit 937939f

Browse files
committed
Add unit tests for getISOLocalDateTime
1 parent 3878ff7 commit 937939f

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/shared/__tests__/dates.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { getISOLocalDateTime } from '../dates';
2+
3+
describe('getISOLocalDateTime', () => {
4+
it('returns proper ISO date', () => {
5+
const date = new Date(Date.UTC(2017, 0, 1, 21, 41, 37));
6+
7+
const ISODate = getISOLocalDateTime(date);
8+
9+
expect(ISODate).toBe('2017-01-01T21:41:37');
10+
});
11+
12+
it('returns nothing when given nothing', () => {
13+
expect(getISOLocalDateTime()).toBeUndefined();
14+
});
15+
16+
it('throws an error when given nonsense data', () => {
17+
const text = 'wololo';
18+
const fn = () => {};
19+
20+
expect(() => getISOLocalDateTime(text)).toThrow();
21+
expect(() => getISOLocalDateTime(fn)).toThrow();
22+
});
23+
});

0 commit comments

Comments
 (0)