deno.land / x / mongoose@6.7.5 / test / helpers / isBsonType.test.js

isBsonType.test.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
'use strict';
const assert = require('assert');const isBsonType = require('../../lib/helpers/isBsonType');
const Decimal128 = require('mongodb').Decimal128;const ObjectId = require('mongodb').ObjectId;
describe('isBsonType', () => { it('true for any object with _bsontype property equal typename', () => { assert.ok(isBsonType({ _bsontype: 'MyType' }, 'MyType')); });
it('true for any object without _bsontype property and undefined typename', () => { assert.ok(isBsonType({ })); });
it('false for any object with _bsontype property different of typename', () => { assert.ok(!isBsonType({ _bsontype: 'MyType' }, 'OtherType')); });
it('false for any object without _bsontype property', () => { assert.ok(!isBsonType({ }, 'OtherType')); });
it('true for Decimal128', () => { assert.ok(isBsonType(new Decimal128('123'), 'Decimal128')); });
it('true for ObjectId', () => { assert.ok(isBsonType(new ObjectId(), 'ObjectID')); });});
mongoose

Version Info

Tagged at
a year ago