|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +const { |
| 4 | + Binary, |
| 5 | + Code, |
| 6 | + DBRef, |
| 7 | + Decimal128, |
| 8 | + Double, |
| 9 | + Int32, |
| 10 | + Long, |
| 11 | + MaxKey, |
| 12 | + MinKey, |
| 13 | + ObjectId, |
| 14 | + BSONRegExp, |
| 15 | + BSONSymbol, |
| 16 | + Timestamp, |
| 17 | + UUID |
| 18 | +} = require('../register-bson'); |
| 19 | + |
| 20 | +describe('_bsontype identifier', () => { |
| 21 | + // The two out of the norm types: |
| 22 | + it('should be equal to ObjectID for ObjectId', () => { |
| 23 | + expect(ObjectId.prototype._bsontype).to.equal('ObjectID'); |
| 24 | + }); |
| 25 | + it('should be equal to Symbol for BSONSymbol', () => { |
| 26 | + expect(BSONSymbol.prototype._bsontype).to.equal('Symbol'); |
| 27 | + }); |
| 28 | + it('should be equal to Timestamp for Timestamp', () => { |
| 29 | + // TODO(NODE-2624): Make Timestamp hold its long value on a property rather than be a subclass |
| 30 | + // Timestamp overrides the value in its constructor |
| 31 | + const timestamp = new Timestamp({ i: 0, t: 0 }); |
| 32 | + expect(timestamp._bsontype).to.equal('Timestamp'); |
| 33 | + expect(Object.getPrototypeOf(timestamp)._bsontype).to.equal('Long'); |
| 34 | + }); |
| 35 | + |
| 36 | + // All equal to their constructor names |
| 37 | + it('should be equal to Binary for Binary', () => { |
| 38 | + expect(Binary.prototype._bsontype).to.equal('Binary'); |
| 39 | + }); |
| 40 | + it('should be equal to Code for Code', () => { |
| 41 | + expect(Code.prototype._bsontype).to.equal('Code'); |
| 42 | + }); |
| 43 | + it('should be equal to DBRef for DBRef', () => { |
| 44 | + expect(DBRef.prototype._bsontype).to.equal('DBRef'); |
| 45 | + }); |
| 46 | + it('should be equal to Decimal128 for Decimal128', () => { |
| 47 | + expect(Decimal128.prototype._bsontype).to.equal('Decimal128'); |
| 48 | + }); |
| 49 | + it('should be equal to Double for Double', () => { |
| 50 | + expect(Double.prototype._bsontype).to.equal('Double'); |
| 51 | + }); |
| 52 | + it('should be equal to Int32 for Int32', () => { |
| 53 | + expect(Int32.prototype._bsontype).to.equal('Int32'); |
| 54 | + }); |
| 55 | + it('should be equal to Long for Long', () => { |
| 56 | + expect(Long.prototype._bsontype).to.equal('Long'); |
| 57 | + }); |
| 58 | + it('should be equal to MaxKey for MaxKey', () => { |
| 59 | + expect(MaxKey.prototype._bsontype).to.equal('MaxKey'); |
| 60 | + }); |
| 61 | + it('should be equal to MinKey for MinKey', () => { |
| 62 | + expect(MinKey.prototype._bsontype).to.equal('MinKey'); |
| 63 | + }); |
| 64 | + it('should be equal to BSONRegExp for BSONRegExp', () => { |
| 65 | + expect(BSONRegExp.prototype._bsontype).to.equal('BSONRegExp'); |
| 66 | + }); |
| 67 | + it('should be equal to UUID for UUID', () => { |
| 68 | + expect(UUID.prototype._bsontype).to.equal('UUID'); |
| 69 | + }); |
| 70 | +}); |
0 commit comments