@@ -14,56 +14,72 @@ const {
1414 BSONRegExp,
1515 BSONSymbol,
1616 Timestamp,
17- UUID
17+ UUID ,
18+ bsonType
1819} = require ( '../register-bson' ) ;
1920
2021describe ( '_bsontype identifier' , ( ) => {
2122 it ( 'should be equal to ObjectId for ObjectId' , ( ) => {
2223 expect ( ObjectId . prototype . _bsontype ) . to . equal ( 'ObjectId' ) ;
24+ expect ( ObjectId . prototype [ bsonType ] ) . to . equal ( 'ObjectId' ) ;
2325 } ) ;
2426 it ( 'should be equal to BSONSymbol for BSONSymbol' , ( ) => {
2527 expect ( BSONSymbol . prototype . _bsontype ) . to . equal ( 'BSONSymbol' ) ;
28+ expect ( BSONSymbol . prototype [ bsonType ] ) . to . equal ( 'BSONSymbol' ) ;
2629 } ) ;
2730 it ( 'should be equal to Timestamp for Timestamp' , ( ) => {
2831 // TODO(NODE-2624): Make Timestamp hold its long value on a property rather than be a subclass
2932 // Timestamp overrides the value in its constructor
3033 const timestamp = new Timestamp ( { i : 0 , t : 0 } ) ;
3134 expect ( timestamp . _bsontype ) . to . equal ( 'Timestamp' ) ;
3235 expect ( Object . getPrototypeOf ( Object . getPrototypeOf ( timestamp ) ) . _bsontype ) . to . equal ( 'Long' ) ;
36+ expect ( timestamp [ bsonType ] ) . to . equal ( 'Timestamp' ) ;
37+ expect ( Object . getPrototypeOf ( Object . getPrototypeOf ( timestamp ) ) [ bsonType ] ) . to . equal ( 'Long' ) ;
3338 } ) ;
3439
3540 // All equal to their constructor names
3641 it ( 'should be equal to Binary for Binary' , ( ) => {
3742 expect ( Binary . prototype . _bsontype ) . to . equal ( 'Binary' ) ;
43+ expect ( Binary . prototype [ bsonType ] ) . to . equal ( 'Binary' ) ;
3844 } ) ;
3945 it ( 'should be equal to Code for Code' , ( ) => {
4046 expect ( Code . prototype . _bsontype ) . to . equal ( 'Code' ) ;
47+ expect ( Code . prototype [ bsonType ] ) . to . equal ( 'Code' ) ;
4148 } ) ;
4249 it ( 'should be equal to DBRef for DBRef' , ( ) => {
4350 expect ( DBRef . prototype . _bsontype ) . to . equal ( 'DBRef' ) ;
51+ expect ( DBRef . prototype [ bsonType ] ) . to . equal ( 'DBRef' ) ;
4452 } ) ;
4553 it ( 'should be equal to Decimal128 for Decimal128' , ( ) => {
4654 expect ( Decimal128 . prototype . _bsontype ) . to . equal ( 'Decimal128' ) ;
55+ expect ( Decimal128 . prototype [ bsonType ] ) . to . equal ( 'Decimal128' ) ;
4756 } ) ;
4857 it ( 'should be equal to Double for Double' , ( ) => {
4958 expect ( Double . prototype . _bsontype ) . to . equal ( 'Double' ) ;
59+ expect ( Double . prototype [ bsonType ] ) . to . equal ( 'Double' ) ;
5060 } ) ;
5161 it ( 'should be equal to Int32 for Int32' , ( ) => {
5262 expect ( Int32 . prototype . _bsontype ) . to . equal ( 'Int32' ) ;
63+ expect ( Int32 . prototype [ bsonType ] ) . to . equal ( 'Int32' ) ;
5364 } ) ;
5465 it ( 'should be equal to Long for Long' , ( ) => {
5566 expect ( Long . prototype . _bsontype ) . to . equal ( 'Long' ) ;
67+ expect ( Long . prototype [ bsonType ] ) . to . equal ( 'Long' ) ;
5668 } ) ;
5769 it ( 'should be equal to MaxKey for MaxKey' , ( ) => {
5870 expect ( MaxKey . prototype . _bsontype ) . to . equal ( 'MaxKey' ) ;
71+ expect ( MaxKey . prototype [ bsonType ] ) . to . equal ( 'MaxKey' ) ;
5972 } ) ;
6073 it ( 'should be equal to MinKey for MinKey' , ( ) => {
6174 expect ( MinKey . prototype . _bsontype ) . to . equal ( 'MinKey' ) ;
75+ expect ( MinKey . prototype [ bsonType ] ) . to . equal ( 'MinKey' ) ;
6276 } ) ;
6377 it ( 'should be equal to BSONRegExp for BSONRegExp' , ( ) => {
6478 expect ( BSONRegExp . prototype . _bsontype ) . to . equal ( 'BSONRegExp' ) ;
79+ expect ( BSONRegExp . prototype [ bsonType ] ) . to . equal ( 'BSONRegExp' ) ;
6580 } ) ;
6681 it ( 'should be equal to Binary for UUID' , ( ) => {
6782 expect ( UUID . prototype . _bsontype ) . to . equal ( 'Binary' ) ;
83+ expect ( UUID . prototype [ bsonType ] ) . to . equal ( 'Binary' ) ;
6884 } ) ;
6985} ) ;
0 commit comments