@@ -46,6 +46,16 @@ describe("DynamoDBStore", () => {
46
46
const sessionId = Math . random ( ) . toString ( ) ;
47
47
48
48
describe ( "Instantiation" , ( ) => {
49
+ let consoleWarnStub ;
50
+
51
+ beforeEach ( ( ) => {
52
+ consoleWarnStub = sinon . stub ( console , 'warn' ) ;
53
+ } )
54
+
55
+ afterEach ( ( ) => {
56
+ consoleWarnStub . restore ( ) ;
57
+ } )
58
+
49
59
it ( "should be able to be created" , ( ) => {
50
60
store . should . be . an . instanceOf ( DynamoDBStore ) ;
51
61
} ) ;
@@ -69,6 +79,33 @@ describe("DynamoDBStore", () => {
69
79
} )
70
80
. finally ( done ) ;
71
81
} ) ;
82
+ < << << << Updated upstream
83
+ = = === ==
84
+
85
+ it ( "should store a valid expiresIn" , ( ) => {
86
+ const store = new DynamoDBStore ( {
87
+ table : "sessions-test" ,
88
+ expiresIn : 3600
89
+ } ) ;
90
+ store . expiresIn . should . equal ( 3600 ) ;
91
+ } ) ;
92
+
93
+ it ( "should revert expiresIn to 0 when set to a non-integer" , ( ) => {
94
+ const store = new DynamoDBStore ( {
95
+ table : "sessions-test" ,
96
+ expiresIn : 1.5
97
+ } ) ;
98
+ store . expiresIn . should . equal ( 0 ) ;
99
+ } ) ;
100
+
101
+ it ( "should revert expiresIn to 0 when set to a negative integer" , ( ) => {
102
+ const store = new DynamoDBStore ( {
103
+ table : "sessions-test" ,
104
+ expiresIn : - 10
105
+ } ) ;
106
+ store . expiresIn . should . equal ( 0 ) ;
107
+ } ) ;
108
+ > >>> >>> Stashed changes
72
109
} ) ;
73
110
74
111
describe ( "Initializing" , ( ) => {
@@ -174,6 +211,16 @@ describe("DynamoDBStore", () => {
174
211
} ) ;
175
212
176
213
describe ( "Setting" , ( ) => {
214
+ let clock ;
215
+
216
+ beforeEach ( ( ) => {
217
+ clock = sinon . useFakeTimers ( 1000000000 ) ;
218
+ } )
219
+
220
+ afterEach ( ( ) => {
221
+ clock . restore ( ) ;
222
+ } )
223
+
177
224
it ( "should store data correctly" , async ( ) => {
178
225
return new Promise ( ( resolve , reject ) => {
179
226
const name = Math . random ( ) . toString ( ) ;
@@ -239,7 +286,6 @@ describe("DynamoDBStore", () => {
239
286
table : tableName ,
240
287
expiresIn : 1000
241
288
} ) ;
242
- const beforeTime = Math . floor ( Date . now ( ) / 1000 ) ;
243
289
244
290
await new Promise ( ( resolve , reject ) => {
245
291
storeWithExpiry . set (
@@ -263,8 +309,7 @@ describe("DynamoDBStore", () => {
263
309
) ;
264
310
265
311
const expiryValue = parseInt ( result . Item . expires . N ) ;
266
- const expectedExpiry = beforeTime + 1000 ;
267
- expiryValue . should . be . approximately ( expectedExpiry , 2 ) ;
312
+ expiryValue . should . equal ( 1000000 + 1000 ) ;
268
313
} ) ;
269
314
} ) ;
270
315
0 commit comments