|
1 | 1 | import { expect } from 'chai'; |
2 | 2 |
|
3 | | -import { Decimal128 } from '../../mongodb'; |
4 | | -import { assert as test, setupDatabase } from '../shared'; |
| 3 | +import { type Collection, Decimal128, type MongoClient } from '../../../src'; |
5 | 4 |
|
6 | 5 | describe('Decimal128', function () { |
7 | | - before(function () { |
8 | | - return setupDatabase(this.configuration); |
| 6 | + let client: MongoClient; |
| 7 | + let collection: Collection; |
| 8 | + |
| 9 | + beforeEach(async function () { |
| 10 | + client = this.configuration.newClient(); |
| 11 | + collection = client.db('decimal128').collection('decimal128'); |
| 12 | + }); |
| 13 | + |
| 14 | + afterEach(async function () { |
| 15 | + await client.close(); |
9 | 16 | }); |
10 | 17 |
|
11 | | - it('should correctly insert decimal128 value', function (done) { |
12 | | - const configuration = this.configuration; |
13 | | - const client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }); |
14 | | - const db = client.db(configuration.db); |
| 18 | + it('should correctly insert decimal128 value', async function () { |
15 | 19 | const object = { |
16 | 20 | id: 1, |
17 | 21 | value: Decimal128.fromString('1.28') |
18 | 22 | }; |
19 | | - |
20 | | - db.collection('decimal128').insertOne(object, function (err) { |
21 | | - expect(err).to.not.exist; |
22 | | - |
23 | | - db.collection('decimal128').findOne( |
24 | | - { |
25 | | - id: 1 |
26 | | - }, |
27 | | - function (err, doc) { |
28 | | - expect(err).to.not.exist; |
29 | | - test.ok(doc.value instanceof Decimal128); |
30 | | - test.equal('1.28', doc.value.toString()); |
31 | | - |
32 | | - client.close(done); |
33 | | - } |
34 | | - ); |
| 23 | + await collection.insertOne(object); |
| 24 | + const doc = await collection.findOne({ |
| 25 | + id: 1 |
35 | 26 | }); |
| 27 | + |
| 28 | + expect(doc.value).to.be.instanceof(Decimal128); |
| 29 | + expect(doc.value.toString()).to.equal('1.28'); |
36 | 30 | }); |
37 | 31 | }); |
0 commit comments