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