@@ -35,6 +35,32 @@ describe('CandleBucketUtil', () => {
35
35
} ) ;
36
36
} ) ;
37
37
38
+ describe ( 'removeUnitISO' , ( ) => {
39
+ it ( 'calculates the previous timestamp' , ( ) => {
40
+ const time = '2020-04-20T11:38:00.000Z' ;
41
+ const granularity = CandleGranularity . ONE_HOUR ;
42
+ const expected = '2020-04-20T10:38:00.000Z' ;
43
+ const actual = CandleBucketUtil . removeUnitISO ( time , granularity , 1 ) ;
44
+ expect ( actual ) . toBe ( expected ) ;
45
+ } ) ;
46
+
47
+ it ( 'works with numbers' , ( ) => {
48
+ const time = new Date ( '2020-04-20T11:38:00.000Z' ) . getTime ( ) ;
49
+ const granularity = CandleGranularity . ONE_HOUR ;
50
+ const expected = '2020-04-20T10:38:00.000Z' ;
51
+ const actual = CandleBucketUtil . removeUnitISO ( time , granularity , 1 ) ;
52
+ expect ( actual ) . toBe ( expected ) ;
53
+ } ) ;
54
+
55
+ it ( 'works with multiple units' , ( ) => {
56
+ const time = '2020-04-20T11:38:00.000Z' ;
57
+ const granularity = CandleGranularity . ONE_MINUTE ;
58
+ const expected = '2020-04-20T11:36:00.000Z' ;
59
+ const actual = CandleBucketUtil . removeUnitISO ( time , granularity , 2 ) ;
60
+ expect ( actual ) . toBe ( expected ) ;
61
+ } ) ;
62
+ } ) ;
63
+
38
64
describe ( 'mapInterval' , ( ) => {
39
65
it ( 'matches a value within a range' , ( ) => {
40
66
const range = [ 60 , 300 , 900 , 3600 , 21600 , 86400 ] ;
0 commit comments