@@ -165,21 +165,29 @@ describe('UUID', () => {
165
165
expect ( inspect ( uuid ) ) . to . equal ( `new UUID("${ LOWERCASE_DASH_SEPARATED_UUID_STRING } ")` ) ;
166
166
} ) ;
167
167
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
+ } ) ;
184
192
} ) ;
185
193
} ) ;
0 commit comments