deno.land / x / mongoose@6.7.5 / test / types.decimal128.test.js

types.decimal128.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
'use strict';
/** * Module dependencies. */
const start = require('./common');
const assert = require('assert');
const mongoose = start.mongoose;const Schema = mongoose.Schema;
/** * Test. */
describe('types.decimal128', function() { it('casts from type number (gh-6331)', function() { const dec128 = new Schema({ value: Schema.Types.Decimal128 });
const BigNum = mongoose.model('gh6331', dec128);
const big = new BigNum({ value: 10000 });
assert.strictEqual(big.value.toString(), '10000'); });
it('uses valueOf method if one exists (gh-6418)', function() { const dec128 = new Schema({ value: Schema.Types.Decimal128 });
mongoose.deleteModel(/Test/); const BigNum = mongoose.model('Test', dec128);
const obj = { str: '10.123', valueOf: function() { return this.str; } };
const big = new BigNum({ value: obj });
assert.strictEqual(big.value.toString(), '10.123'); });});
mongoose

Version Info

Tagged at
a year ago