@@ -17,7 +17,8 @@ describe('Timestamp', function () {
1717 new BSON . Timestamp ( new BSON . Long ( 0xffffffff , 0xfffffffff , false ) ) ,
1818 new BSON . Timestamp ( new BSON . Long ( 0xffffffff , 0xfffffffff , true ) ) ,
1919 new BSON . Timestamp ( { t : 0xffffffff , i : 0xfffffffff } ) ,
20- new BSON . Timestamp ( { t : - 1 , i : - 1 } )
20+ new BSON . Timestamp ( { t : - 1 , i : - 1 } ) ,
21+ new BSON . Timestamp ( { t : new BSON . Int32 ( 0xffffffff ) , i : new BSON . Int32 ( 0xffffffff ) } )
2122 ] . forEach ( timestamp => {
2223 expect ( timestamp ) . to . have . property ( 'unsigned' , true ) ;
2324 } ) ;
@@ -37,4 +38,10 @@ describe('Timestamp', function () {
3738 const timestamp = new BSON . Timestamp ( input ) ;
3839 expect ( timestamp . toExtendedJSON ( ) ) . to . deep . equal ( { $timestamp : input } ) ;
3940 } ) ;
41+
42+ it ( 'should accept a { t, i } object as constructor input and coerce to integer' , function ( ) {
43+ const input = { t : new BSON . Int32 ( 89 ) , i : new BSON . Int32 ( 144 ) } ;
44+ const timestamp = new BSON . Timestamp ( input ) ;
45+ expect ( timestamp . toExtendedJSON ( ) ) . to . deep . equal ( { $timestamp : { t : 89 , i : 144 } } ) ;
46+ } ) ;
4047} ) ;
0 commit comments