Skip to content

Commit

Permalink
fixup: review comment
Browse files Browse the repository at this point in the history
  • Loading branch information
addaleax committed Aug 2, 2021
1 parent c6de2da commit 0a58875
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion test/node/timestamp_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ describe('Timestamp', function () {
new BSON.Timestamp(new BSON.Long(0xffffffff, 0xfffffffff, false)),
new BSON.Timestamp(new BSON.Long(0xffffffff, 0xfffffffff, true)),
new BSON.Timestamp({ t: 0xffffffff, i: 0xfffffffff }),
new BSON.Timestamp({ t: -1, i: -1 })
new BSON.Timestamp({ t: -1, i: -1 }),
new BSON.Timestamp({ t: new BSON.Int32(0xffffffff), i: new BSON.Int32(0xffffffff) })
].forEach(timestamp => {
expect(timestamp).to.have.property('unsigned', true);
});
Expand All @@ -37,4 +38,10 @@ describe('Timestamp', function () {
const timestamp = new BSON.Timestamp(input);
expect(timestamp.toExtendedJSON()).to.deep.equal({ $timestamp: input });
});

it('should accept a { t, i } object as constructor input and coerce to integer', function () {
const input = { t: new BSON.Int32(89), i: new BSON.Int32(144) };
const timestamp = new BSON.Timestamp(input);
expect(timestamp.toExtendedJSON()).to.deep.equal({ $timestamp: { t: 89, i: 144 } });
});
});

0 comments on commit 0a58875

Please sign in to comment.