|
1 | 1 | import { |
2 | | - getHoursMinutes, |
3 | | - getHoursMinutesSeconds, |
4 | 2 | convert12to24, |
5 | 3 | convert24to12, |
6 | 4 | } from './dates'; |
7 | 5 |
|
8 | | -describe('getHoursMinutes', () => { |
9 | | - it('returns proper hour and minute for a given date', () => { |
10 | | - const date = new Date(2017, 0, 1, 16, 4); |
11 | | - |
12 | | - const hoursMinutes = getHoursMinutes(date); |
13 | | - |
14 | | - expect(hoursMinutes).toBe('16:04'); |
15 | | - }); |
16 | | - |
17 | | - it('returns proper hour and minute for a given string of hour and minute', () => { |
18 | | - const date = '16:04'; |
19 | | - |
20 | | - const hoursMinutes = getHoursMinutes(date); |
21 | | - |
22 | | - expect(hoursMinutes).toBe('16:04'); |
23 | | - }); |
24 | | - |
25 | | - it('returns proper hour and minute for a given string of hour, minute and second', () => { |
26 | | - const date = '16:04:08'; |
27 | | - |
28 | | - const hoursMinutes = getHoursMinutes(date); |
29 | | - |
30 | | - expect(hoursMinutes).toBe('16:04'); |
31 | | - }); |
32 | | - |
33 | | - it('throws an error when given nonsense data', () => { |
34 | | - const text = 'wololo'; |
35 | | - const flag = true; |
36 | | - |
37 | | - expect(() => getHoursMinutes(text)).toThrow(); |
38 | | - expect(() => getHoursMinutes(flag)).toThrow(); |
39 | | - }); |
40 | | -}); |
41 | | - |
42 | | -describe('getHoursMinutesSeconds', () => { |
43 | | - it('returns proper hour, minute and second for a given date', () => { |
44 | | - const date = new Date(2017, 0, 1, 16, 4, 41); |
45 | | - |
46 | | - const hoursMinutesSeconds = getHoursMinutesSeconds(date); |
47 | | - |
48 | | - expect(hoursMinutesSeconds).toBe('16:04:41'); |
49 | | - }); |
50 | | - |
51 | | - it('returns proper hour, minute and second for a given string of hour and minute', () => { |
52 | | - const date = '16:04'; |
53 | | - |
54 | | - const hoursMinutesSeconds = getHoursMinutesSeconds(date); |
55 | | - |
56 | | - expect(hoursMinutesSeconds).toBe('16:04:00'); |
57 | | - }); |
58 | | - |
59 | | - it('returns proper hour, minute and second for a given string of hour, minute and second', () => { |
60 | | - const date = '16:04:08'; |
61 | | - |
62 | | - const hoursMinutesSeconds = getHoursMinutesSeconds(date); |
63 | | - |
64 | | - expect(hoursMinutesSeconds).toBe('16:04:08'); |
65 | | - }); |
66 | | - |
67 | | - it('throws an error when given nonsense data', () => { |
68 | | - const text = 'wololo'; |
69 | | - const flag = true; |
70 | | - |
71 | | - expect(() => getHoursMinutesSeconds(text)).toThrow(); |
72 | | - expect(() => getHoursMinutesSeconds(flag)).toThrow(); |
73 | | - }); |
74 | | -}); |
75 | | - |
76 | 6 | describe('convert12to24', () => { |
77 | 7 | it.each` |
78 | 8 | hour12 | amPm | hour24 |
|
0 commit comments