@tomsd/mongodbclient 2.1.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/test/test.js +26 -52
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomsd/mongodbclient",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "",
5
5
  "main": "dist/cjs/mongodbclient.js",
6
6
  "module": "dist/esm/mongodbclient.js",
package/test/test.js CHANGED
@@ -14,71 +14,45 @@ const items = [
14
14
  {name:"alice"}
15
15
  ];
16
16
 
17
- describe("MClient", function(){
18
- it("insertMany()",function(done){
19
- mdbc.insertMany(items)
20
- .then(function(r){
21
- assert.equal(r.insertedCount, items.length);
22
- done();
23
- });
17
+ describe("MClient", () => {
18
+ it("insertMany()", async () => {
19
+ const { insertedCount } = await mdbc.insertMany(items)
20
+ assert.equal(insertedCount, items.length);
24
21
  });
25
22
 
26
- it("getCollections()", function(done){
27
- mdbc.getCollections()
28
- .then(function(collections){
29
- assert(collections.length > 0);
30
- done();
31
- });
23
+ it("getCollections()", async () => {
24
+ const collections = await mdbc.getCollections();
25
+ assert(collections.length > 0);
32
26
  });
33
27
 
34
- it("read()", function(done){
35
- mdbc.read()
36
- .then(function(docs){
37
- assert.equal(docs.length, items.length);
38
- done();
39
- });
28
+ it("read()", async () => {
29
+ const docs = await mdbc.read();
30
+ assert.equal(docs.length, items.length);
40
31
  });
41
32
 
42
- it("upsert()", function(done){
43
- mdbc.read()
44
- .then(function(docs){
45
- return mdbc.upsert({_id:docs[0]._id, name:"david"});
46
- })
47
- .then(function(r){
48
- assert.equal(r.modifiedCount, 1);
49
- done();
50
- });
33
+ it("upsert()", async () => {
34
+ const docs = await mdbc.read();
35
+ const { modifiedCount } = await mdbc.upsert({ _id: docs[0]._id, name: "david" });
36
+ assert.equal(modifiedCount, 1);
51
37
  });
52
38
 
53
- it("distinct()", function(done){
54
- mdbc.distinct("name")
55
- .then(function(names){
56
- assert.equal(names.length, 4);
57
- done();
58
- });
39
+ it("distinct()", async () => {
40
+ const names = await mdbc.distinct("name");
41
+ assert.equal(names.length, 4);
59
42
  });
60
43
 
61
- it("stats()", function(done){
62
- mdbc.stats()
63
- .then(function(r){
64
- assert(r.storageSize > 0);
65
- done();
66
- });
44
+ it("stats()", async () => {
45
+ const { storageSize } = await mdbc.stats();
46
+ assert(storageSize > 0);
67
47
  });
68
48
 
69
- it("count()", function(done){
70
- mdbc.count({name:"alice"})
71
- .then(function(n){
72
- assert.equal(n,1);
73
- done();
74
- });
49
+ it("count()", async () => {
50
+ const n = await mdbc.count({name:"alice"});
51
+ assert.equal(n,1);
75
52
  });
76
53
 
77
- it("remove()", function(done){
78
- mdbc.remove()
79
- .then(function(r){
80
- assert.equal(r.deletedCount, items.length);
81
- done();
82
- });
54
+ it("remove()", async () => {
55
+ const { deletedCount } = await mdbc.remove();
56
+ assert.equal(deletedCount, items.length);
83
57
  });
84
58
  });