w-orm-mongodb 1.1.32 → 1.1.34

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.
package/test/gfs.test.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import assert from 'assert'
2
2
  import path from 'path'
3
3
  import fs from 'fs'
4
- import wo from '../src/WOrmMongodb.mjs'
4
+ import WOrm from '../src/WOrmMongodb.mjs'
5
5
 
6
6
 
7
7
  function isWindows() {
@@ -15,52 +15,44 @@ if (isWindows()) {
15
15
  let vans = {}
16
16
  let vget = {}
17
17
 
18
-
19
18
  before(async function () {
20
19
 
21
-
22
20
  let opt = {
23
21
  url: 'mongodb://username:password@127.0.0.1:27017',
24
22
  db: 'worm',
25
23
  cl: 'usersGfs',
26
24
  }
27
25
 
28
-
29
- //w
30
- let w = wo(opt)
31
-
26
+ //wo
27
+ let wo = WOrm(opt)
32
28
 
33
29
  //on
34
- w.on('change', function(mode, data, res) {
30
+ wo.on('change', function(mode, data, res) {
35
31
  // console.log('change', mode)
36
32
  })
37
33
 
38
-
39
34
  //fn_in, fn_out
40
35
  let fn_in = path.resolve('../', './_data', 'data(in).dat')
41
36
  let fn_out = path.resolve('../', './_data', 'data(out).dat')
42
37
  // console.log('fn_in', fn_in)
43
38
  // console.log('fn_out', fn_out)
44
39
 
45
-
46
40
  //unlinkSync
47
41
  try {
48
42
  fs.unlinkSync(fn_out)
49
43
  }
50
44
  catch (err) {}
51
45
 
52
-
53
46
  //u8a
54
47
  let b = await fs.readFileSync(fn_in)
55
48
  let u8a = new Uint8Array(b)
56
49
  // let u8a = new Uint8Array([66, 97, 115]) //Uint8Array data from nodejs or browser
57
50
  // console.log('u8a', u8a)
58
51
 
59
-
60
52
  //delAllGfs
61
53
  rt = null
62
54
  vans[1] = { n: 0, ok: 1 }
63
- await w.delAllGfs()
55
+ await wo.delAllGfs()
64
56
  .then(function(msg) {
65
57
  // console.log('delAllGfs then', msg)
66
58
  // delAllGfs then { n: 0, ok: 1 }
@@ -72,7 +64,6 @@ if (isWindows()) {
72
64
  })
73
65
  vget[1] = rt
74
66
 
75
-
76
67
  //insertGfs
77
68
  let gi = null
78
69
  rt = null
@@ -81,7 +72,7 @@ if (isWindows()) {
81
72
  ok: 1,
82
73
  // id: {random id},
83
74
  }
84
- await w.insertGfs(u8a)
75
+ await wo.insertGfs(u8a)
85
76
  .then(function(msg) {
86
77
  // console.log('insertGfs then', msg)
87
78
  // insertGfs { n: 1, ok: 1, id: {random id} }
@@ -97,7 +88,6 @@ if (isWindows()) {
97
88
  })
98
89
  vget[2] = rt
99
90
 
100
-
101
91
  //selectGfs
102
92
  rt = null
103
93
  vans[3] = [
@@ -108,7 +98,7 @@ if (isWindows()) {
108
98
  102,
109
99
  47381362,
110
100
  ]
111
- await w.selectGfs(gi.id)
101
+ await wo.selectGfs(gi.id)
112
102
  .then(function(msg) {
113
103
  // console.log('selectGfs then', msg)
114
104
  // console.log('msg[0]', msg[0], msg[0] === 0)
@@ -145,11 +135,10 @@ if (isWindows()) {
145
135
  })
146
136
  vget[3] = rt
147
137
 
148
-
149
138
  //delGfs
150
139
  rt = null
151
140
  vans[4] = { n: 1, nDeleted: 1, ok: 1 }
152
- await w.delGfs(gi.id)
141
+ await wo.delGfs(gi.id)
153
142
  .then(function(msg) {
154
143
  // console.log('delGfs then', msg)
155
144
  // delGfs { n: 1, nDeleted: 1, ok: 1 }
@@ -161,29 +150,23 @@ if (isWindows()) {
161
150
  })
162
151
  vget[4] = rt
163
152
 
164
-
165
153
  })
166
154
 
167
-
168
155
  it(`should get ${JSON.stringify(vans[1])} for delAllGfs`, function() {
169
156
  assert.strict.deepStrictEqual(vget[1], vans[1])
170
157
  })
171
158
 
172
-
173
159
  it(`should get ${JSON.stringify(vans[2])} for insertGfs`, async function() {
174
160
  assert.strict.deepStrictEqual(vget[2], vans[2])
175
161
  })
176
162
 
177
-
178
163
  it(`should get ${JSON.stringify(vans[3])} for selectGfs`, async function() {
179
164
  assert.strict.deepStrictEqual(vget[3], vans[3])
180
165
  })
181
166
 
182
-
183
167
  it(`should get ${JSON.stringify(vans[4])} for delGfs`, async function() {
184
168
  assert.strict.deepStrictEqual(vget[4], vans[4])
185
169
  })
186
170
 
187
-
188
171
  })
189
172
  }