Skip to content

Commit 933b6e6

Browse files
Added toBinary test
1 parent b990257 commit 933b6e6

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

test/node/uuid_tests.js

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -165,21 +165,29 @@ describe('UUID', () => {
165165
expect(inspect(uuid)).to.equal(`new UUID("${LOWERCASE_DASH_SEPARATED_UUID_STRING}")`);
166166
});
167167

168-
it(`should serialize as a valid UUID _bsontype with Object input without error`, () => {
169-
const output = BSON.serialize({ uuid: new BSON.UUID() });
170-
expect(output[4]).to.equal(BSON_DATA_BINARY);
171-
expect(output[14]).to.equal(BSON_BINARY_SUBTYPE_UUID_NEW);
172-
});
173-
174-
it(`should serialize as a valid UUID _bsontype with Map input without error`, () => {
175-
const output = BSON.serialize(new Map([['uuid', new BSON.UUID()]]));
176-
expect(output[4]).to.equal(BSON_DATA_BINARY);
177-
expect(output[14]).to.equal(BSON_BINARY_SUBTYPE_UUID_NEW);
178-
});
179-
180-
it(`should serialize as a valid UUID _bsontype with Array input without error`, () => {
181-
const output = BSON.serialize({ a: [new BSON.UUID()] });
182-
expect(output[11]).to.equal(BSON_DATA_BINARY);
183-
expect(output[18]).to.equal(BSON_BINARY_SUBTYPE_UUID_NEW);
168+
describe('serialize', () => {
169+
it('should have a valid UUID _bsontype with Object input without error', () => {
170+
const output = BSON.serialize({ uuid: new BSON.UUID() });
171+
expect(output[4]).to.equal(BSON_DATA_BINARY);
172+
expect(output[14]).to.equal(BSON_BINARY_SUBTYPE_UUID_NEW);
173+
});
174+
175+
it('should have a valid UUID _bsontype with Map input without error', () => {
176+
const output = BSON.serialize(new Map([['uuid', new BSON.UUID()]]));
177+
expect(output[4]).to.equal(BSON_DATA_BINARY);
178+
expect(output[14]).to.equal(BSON_BINARY_SUBTYPE_UUID_NEW);
179+
});
180+
181+
it('should have as a valid UUID _bsontype with Array input without error', () => {
182+
const output = BSON.serialize({ a: [new BSON.UUID()] });
183+
expect(output[11]).to.equal(BSON_DATA_BINARY);
184+
expect(output[18]).to.equal(BSON_BINARY_SUBTYPE_UUID_NEW);
185+
});
186+
187+
it('should serialize BSON.UUID() input the same as BSON.UUID().toBinary()', () => {
188+
const toBinarySerialization = BSON.serialize({ uuid: new BSON.UUID().toBinary() });
189+
const plainUUIDSerialization = BSON.serialize({ uuid: new BSON.UUID() });
190+
expect(plainUUIDSerialization).to.deep.equal(toBinarySerialization);
191+
});
184192
});
185193
});

0 commit comments

Comments
 (0)