Skip to content

Commit 78dfe9e

Browse files
committed
test(NODE-7165): use direct import from src, use async/await
1 parent 8b9f7ac commit 78dfe9e

1 file changed

Lines changed: 18 additions & 24 deletions

File tree

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,31 @@
11
import { expect } from 'chai';
22

3-
import { Decimal128 } from '../../mongodb';
4-
import { assert as test, setupDatabase } from '../shared';
3+
import { type Collection, Decimal128, type MongoClient } from '../../../src';
54

65
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();
916
});
1017

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 () {
1519
const object = {
1620
id: 1,
1721
value: Decimal128.fromString('1.28')
1822
};
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
3526
});
27+
28+
expect(doc.value).to.be.instanceof(Decimal128);
29+
expect(doc.value.toString()).to.equal('1.28');
3630
});
3731
});

0 commit comments

Comments
 (0)