1
1
import {
2
2
truncateTTLToDuration ,
3
+ truncateTTLToFirstUnit ,
3
4
truncateTTLToRange ,
4
5
truncateTTLToSeconds ,
5
6
} from '../truncateTTL'
@@ -101,16 +102,15 @@ describe('Truncate TTL util tests', () => {
101
102
const expectedResponse2 = '25 min, 34 s'
102
103
const expectedResponse3 = '15 h, 5 min, 34 s'
103
104
const expectedResponse4 = '1 mo, 19 d, 1 h, 33 min, 54 s'
104
- // TODO started failing
105
- // const expectedResponse5 = '3 yr, 6 mo, 19 d, 10 h, 32 min, 10 s';
106
- // const expectedResponse6 = '67 yr, 2 mo, 6 d, 12 h, 38 min, 20 s';
105
+ const expectedResponse5 = '3 yr, 6 mo, 19 d, 10 h, 32 min, 10 s'
106
+ const expectedResponse6 = '67 yr, 2 mo, 6 d, 12 h, 38 min, 20 s'
107
107
108
108
expect ( truncateTTLToDuration ( ttl1 ) ) . toEqual ( expectedResponse1 )
109
109
expect ( truncateTTLToDuration ( ttl2 ) ) . toEqual ( expectedResponse2 )
110
110
expect ( truncateTTLToDuration ( ttl3 ) ) . toEqual ( expectedResponse3 )
111
111
expect ( truncateTTLToDuration ( ttl4 ) ) . toEqual ( expectedResponse4 )
112
- // expect(truncateTTLToDuration(ttl5)).toEqual(expectedResponse5);
113
- // expect(truncateTTLToDuration(ttl6)).toEqual(expectedResponse6);
112
+ expect ( truncateTTLToDuration ( ttl5 ) ) . toEqual ( expectedResponse5 )
113
+ expect ( truncateTTLToDuration ( ttl6 ) ) . toEqual ( expectedResponse6 )
114
114
} )
115
115
} )
116
116
@@ -132,4 +132,29 @@ describe('Truncate TTL util tests', () => {
132
132
expect ( truncateTTLToSeconds ( ttl4 ) ) . toEqual ( expectedResponse4 )
133
133
} )
134
134
} )
135
+
136
+ describe ( 'truncateTTLToFirstUnit' , ( ) => {
137
+ it ( 'truncateTTLToFirstUnit should return appropriate value' , ( ) => {
138
+ const ttl1 = 100
139
+ const ttl2 = 1_534
140
+ const ttl3 = 54_334
141
+ const ttl4 = 4_325_634
142
+ const ttl5 = 112_012_330
143
+ const ttl6 = 2_120_042_300
144
+
145
+ const expectedResponse1 = '1 min' // '1 min, 40 s'
146
+ const expectedResponse2 = '25 min' // '25 min, 34 s'
147
+ const expectedResponse3 = '15 h' // '15 h, 5 min, 34 s'
148
+ const expectedResponse4 = '1 mo' // '1 mo, 19 d, 1 h, 33 min, 54 s'
149
+ const expectedResponse5 = '3 yr' // '3 yr, 6 mo, 19 d, 10 h, 32 min, 10 s'
150
+ const expectedResponse6 = '67 yr' // '67 yr, 2 mo, 6 d, 12 h, 38 min, 20 s'
151
+
152
+ expect ( truncateTTLToFirstUnit ( ttl1 ) ) . toEqual ( expectedResponse1 )
153
+ expect ( truncateTTLToFirstUnit ( ttl2 ) ) . toEqual ( expectedResponse2 )
154
+ expect ( truncateTTLToFirstUnit ( ttl3 ) ) . toEqual ( expectedResponse3 )
155
+ expect ( truncateTTLToFirstUnit ( ttl4 ) ) . toEqual ( expectedResponse4 )
156
+ expect ( truncateTTLToFirstUnit ( ttl5 ) ) . toEqual ( expectedResponse5 )
157
+ expect ( truncateTTLToFirstUnit ( ttl6 ) ) . toEqual ( expectedResponse6 )
158
+ } )
159
+ } )
135
160
} )
0 commit comments