@@ -89,42 +89,84 @@ describe('extractPushTime', () => {
89
89
describe ( 'extractExpirationTime' , ( ) => {
90
90
describe ( 'With expiration interval' , ( ) => {
91
91
describe ( 'In user\'s local timezone' , ( ) => {
92
- const changes = {
93
- "experiment_name" : "" ,
94
- "exp_size_in_percent" : 50 ,
95
- "push_time_type" : "time" ,
96
- "push_time" : "2017-09-28T19:40:00.000" ,
97
- "push_time_1" : null ,
98
- "push_time_2" : null ,
99
- "push_time_iso" : "2017-09-28T23:40:00.000Z" ,
100
- "push_time_1_iso" : null ,
101
- "push_time_2_iso" : null ,
102
- "deliveryTime" : null ,
103
- "local_time" : true ,
104
- "push_expires" : true ,
105
- "expiration_time" : null ,
106
- "expiration_time_type" : "interval" ,
107
- "expiration_interval_num" : "3" ,
108
- "expiration_interval_unit" : "hours" ,
109
- "expirationInterval" : null ,
110
- "exp_type" : "message" ,
111
- "exp_enable" : null ,
112
- "increment_badge" : null ,
113
- "audience_id" : "everyone" ,
114
- "data" : "asdsada" ,
115
- "data_type" : "text" ,
116
- "data1" : "" ,
117
- "data_type_1" : "text" ,
118
- "data2" : "" ,
119
- "data_type_2" : "text" ,
120
- "translation_enable" : null
121
- } ;
92
+ describe ( 'In hours' , ( ) => {
93
+ const changes = {
94
+ "experiment_name" : "" ,
95
+ "exp_size_in_percent" : 50 ,
96
+ "push_time_type" : "time" ,
97
+ "push_time" : "2017-09-28T19:40:00.000" ,
98
+ "push_time_1" : null ,
99
+ "push_time_2" : null ,
100
+ "push_time_iso" : "2017-09-28T23:40:00.000Z" ,
101
+ "push_time_1_iso" : null ,
102
+ "push_time_2_iso" : null ,
103
+ "deliveryTime" : null ,
104
+ "local_time" : true ,
105
+ "push_expires" : true ,
106
+ "expiration_time" : null ,
107
+ "expiration_time_type" : "interval" ,
108
+ "expiration_interval_num" : "3" ,
109
+ "expiration_interval_unit" : "hours" ,
110
+ "expirationInterval" : null ,
111
+ "exp_type" : "message" ,
112
+ "exp_enable" : null ,
113
+ "increment_badge" : null ,
114
+ "audience_id" : "everyone" ,
115
+ "data" : "asdsada" ,
116
+ "data_type" : "text" ,
117
+ "data1" : "" ,
118
+ "data_type_1" : "text" ,
119
+ "data2" : "" ,
120
+ "data_type_2" : "text" ,
121
+ "translation_enable" : null
122
+ } ;
122
123
123
- it ( 'should return a relative time in seconds' , ( ) => {
124
- const push_time = extractPushTime ( changes ) ;
125
- const expiration_time = extractExpirationTime ( changes , push_time ) ;
124
+ it ( 'should return a relative time in seconds' , ( ) => {
125
+ const push_time = extractPushTime ( changes ) ;
126
+ const expiration_time = extractExpirationTime ( changes , push_time ) ;
127
+
128
+ expect ( expiration_time ) . toBe ( 3 * 60 * 60 ) ; // 3 hours in seconds
129
+ } ) ;
130
+ } ) ;
131
+
132
+ describe ( 'In days' , ( ) => {
133
+ const changes = {
134
+ "experiment_name" : "" ,
135
+ "exp_size_in_percent" : 50 ,
136
+ "push_time_type" : "time" ,
137
+ "push_time" : "2017-09-28T19:40:00.000" ,
138
+ "push_time_1" : null ,
139
+ "push_time_2" : null ,
140
+ "push_time_iso" : "2017-09-28T23:40:00.000Z" ,
141
+ "push_time_1_iso" : null ,
142
+ "push_time_2_iso" : null ,
143
+ "deliveryTime" : null ,
144
+ "local_time" : true ,
145
+ "push_expires" : true ,
146
+ "expiration_time" : null ,
147
+ "expiration_time_type" : "interval" ,
148
+ "expiration_interval_num" : "2" ,
149
+ "expiration_interval_unit" : "days" ,
150
+ "expirationInterval" : null ,
151
+ "exp_type" : "message" ,
152
+ "exp_enable" : null ,
153
+ "increment_badge" : null ,
154
+ "audience_id" : "everyone" ,
155
+ "data" : "asdsada" ,
156
+ "data_type" : "text" ,
157
+ "data1" : "" ,
158
+ "data_type_1" : "text" ,
159
+ "data2" : "" ,
160
+ "data_type_2" : "text" ,
161
+ "translation_enable" : null
162
+ } ;
163
+
164
+ it ( 'should return a relative time in seconds' , ( ) => {
165
+ const push_time = extractPushTime ( changes ) ;
166
+ const expiration_time = extractExpirationTime ( changes , push_time ) ;
126
167
127
- expect ( expiration_time ) . toBe ( 3 * 60 * 60 ) ;
168
+ expect ( expiration_time ) . toBe ( 2 * 24 * 3600 ) ; // 2 days in seconds
169
+ } ) ;
128
170
} ) ;
129
171
} ) ;
130
172
0 commit comments