Skip to content

Commit 40e9f2d

Browse files
authored
update ava dependency from 2.1.0 to 5.3.0 (#266)
* update ava dependency from 2.1.0 to 5.3.0 * update used of throws to always pass expectation object
1 parent d461a21 commit 40e9f2d

11 files changed

+1623
-5269
lines changed

package-lock.json

+1,576-5,222
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "lib/main.js",
66
"typings": "lib/main.d.ts",
77
"engines": {
8-
"node": ">=6.0.0"
8+
"node": ">=18.0.0"
99
},
1010
"directories": {
1111
"test": "tests"
@@ -41,7 +41,7 @@
4141
"devDependencies": {
4242
"@types/node": "^12.0.10",
4343
"@types/swagger-schema-official": "^2.0.17",
44-
"ava": "^2.1.0",
44+
"ava": "^5.3.0",
4545
"codecov": "^3.5.0",
4646
"jszip": "^3.1.3",
4747
"nock": "^11.7.0",

test/unit/actions.test.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ test('create a new action with concurrency setting', t => {
477477

478478
test('create an action without providing an action body', t => {
479479
const actions = new Actions()
480-
t.throws(() => actions.create({ name: '12345' }), /Missing mandatory action/)
480+
t.throws(() => actions.create({ name: '12345' }), { message: /Missing mandatory action/ })
481481
})
482482

483483
test('create a new action with version parameter', t => {
@@ -556,23 +556,23 @@ test('creating sequence action with invalid sequence parameter', t => {
556556

557557
const actions = new Actions(client)
558558

559-
t.throws(() => actions.create({ name: '12345', sequence: 'string' }), /Invalid sequence parameter/)
560-
t.throws(() => actions.create({ name: '12345', sequence: { foo: 'bar' } }), /Invalid sequence parameter/)
559+
t.throws(() => actions.create({ name: '12345', sequence: 'string' }), { message: /Invalid sequence parameter/ })
560+
t.throws(() => actions.create({ name: '12345', sequence: { foo: 'bar' } }), { message: /Invalid sequence parameter/ })
561561
})
562562

563563
test('creating sequence action with empty array', t => {
564564
const client = {}
565565

566566
const actions = new Actions(client)
567567

568-
t.throws(() => actions.create({ name: '12345', sequence: [] }), /Invalid sequence parameter/)
568+
t.throws(() => actions.create({ name: '12345', sequence: [] }), { message: /Invalid sequence parameter/ })
569569
})
570570

571571
test('creating action with both sequence and action parameters', t => {
572572
const client = {}
573573
const actions = new Actions(client)
574574

575-
t.throws(() => actions.create({ name: '12345', action: 'function main() {}', sequence: 'string' }), /Invalid options parameters/)
575+
t.throws(() => actions.create({ name: '12345', action: 'function main() {}', sequence: 'string' }), { message: /Invalid options parameters/ })
576576
})
577577

578578
test('should pass through requested User-Agent header', t => {

test/unit/activations.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -197,5 +197,5 @@ test('should throw when retrieving activation without id', t => {
197197
const activations = new Activations()
198198
return t.throws(() => {
199199
activations.get()
200-
}, /Missing mandatory/)
200+
}, { message: /Missing mandatory/ })
201201
})

test/unit/client.test.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,11 @@ test('should use options for parameters even if environment parameters are avail
260260
})
261261

262262
test('should throw error when missing API key option.', t => {
263-
t.throws(() => new Client({ api: true }), /Missing api_key parameter./)
263+
t.throws(() => new Client({ api: true }), { message: /Missing api_key parameter./ })
264264
})
265265

266266
test('should throw error when missing both API and API Host options.', t => {
267-
t.throws(() => new Client({ api_key: true }), /Missing either api or apihost parameters/)
267+
t.throws(() => new Client({ api_key: true }), { message: /Missing either api or apihost parameters/ })
268268
})
269269

270270
test('should handle multiple api parameter formats', t => {
@@ -403,7 +403,7 @@ test('should return path and status code in error message', t => {
403403
t.throws(() => client.handleErrors({
404404
options: { method, url },
405405
statusCode
406-
}), `${method} ${url} Returned HTTP ${statusCode} (${http.STATUS_CODES[statusCode]}) --> "Response Missing Error Message."`)
406+
}), { message: `${method} ${url} Returned HTTP ${statusCode} (${http.STATUS_CODES[statusCode]}) --> "Response Missing Error Message."` })
407407
})
408408

409409
test('should return response error string in error message', t => {
@@ -415,27 +415,27 @@ test('should return response error string in error message', t => {
415415
error: { error: 'hello' },
416416
options: { method, url },
417417
statusCode
418-
}), `${method} ${url} Returned HTTP ${statusCode} (${http.STATUS_CODES[statusCode]}) --> "hello"`)
418+
}), { message: `${method} ${url} Returned HTTP ${statusCode} (${http.STATUS_CODES[statusCode]}) --> "hello"` })
419419
t.throws(() => client.handleErrors({
420420
error: { response: { result: { error: 'hello' } } },
421421
options: { method, url },
422422
statusCode
423-
}), `${method} ${url} Returned HTTP ${statusCode} (${http.STATUS_CODES[statusCode]}) --> "hello"`)
423+
}), { message: `${method} ${url} Returned HTTP ${statusCode} (${http.STATUS_CODES[statusCode]}) --> "hello"` })
424424
t.throws(() => client.handleErrors({
425425
error: { response: { result: { error: { error: 'hello' } } } },
426426
options: { method, url },
427427
statusCode
428-
}), `${method} ${url} Returned HTTP ${statusCode} (${http.STATUS_CODES[statusCode]}) --> "hello"`)
428+
}), { message: `${method} ${url} Returned HTTP ${statusCode} (${http.STATUS_CODES[statusCode]}) --> "hello"` })
429429
t.throws(() => client.handleErrors({
430430
error: { response: { result: { error: { statusCode: 404 } } } },
431431
options: { method, url },
432432
statusCode
433-
}), `${method} ${url} Returned HTTP ${statusCode} (${http.STATUS_CODES[statusCode]}) --> "application error, status code: ${404}"`)
433+
}), { message: `${method} ${url} Returned HTTP ${statusCode} (${http.STATUS_CODES[statusCode]}) --> "application error, status code: ${404}"` })
434434
})
435435

436436
test('should throw errors for non-HTTP response failures', t => {
437437
const client = new Client({ api_key: true, api: true })
438-
t.throws(() => client.handleErrors({ message: 'error message' }), /error message/)
438+
t.throws(() => client.handleErrors({ message: 'error message' }), { message: /error message/ })
439439
})
440440

441441
test('should contain x-namespace-id header when namespace in constructor options', async t => {

test/unit/feeds.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -303,11 +303,11 @@ test('should be able to update feed', t => {
303303
test('should throw errors without trigger parameter ', t => {
304304
const client = { options: {} }
305305
const feeds = new Feeds(client)
306-
t.throws(() => feeds.feed('', { feedName: 'myFeed' }), /trigger/)
306+
t.throws(() => feeds.feed('', { feedName: 'myFeed' }), { message: /trigger/ })
307307
})
308308

309309
test('should throw errors without id parameter', t => {
310310
const client = { options: {} }
311311
const feeds = new Feeds(client)
312-
t.throws(() => feeds.feed('', { trigger: 'myFeed' }), /feedName/)
312+
t.throws(() => feeds.feed('', { trigger: 'myFeed' }), { message: /feedName/ })
313313
})

test/unit/names.test.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,16 @@ test('should parse namespace from resource with explicit ns and package but miss
5151
})
5252

5353
test('should throw error parsing namespace with only namespace', t => {
54-
t.throws(() => names.parseNamespace('/ns'), /Invalid resource identifier/)
54+
t.throws(() => names.parseNamespace('/ns'), { message: /Invalid resource identifier/ })
5555
})
5656

5757
test('should throw error parsing namespace with only extra paths', t => {
58-
t.throws(() => names.parseNamespace('/ns/pkg/action/extra'), /Invalid resource identifier/)
59-
t.throws(() => names.parseNamespace('ns/pkg/action/extra'), /Invalid resource identifier/)
58+
t.throws(() => names.parseNamespace('/ns/pkg/action/extra'), { message: /Invalid resource identifier/ })
59+
t.throws(() => names.parseNamespace('ns/pkg/action/extra'), { message: /Invalid resource identifier/ })
6060
})
6161

6262
test('should throw error parsing namespace with missing parts', t => {
63-
t.throws(() => names.parseNamespace('/'), /Invalid resource identifier/)
63+
t.throws(() => names.parseNamespace('/'), { message: /Invalid resource identifier/ })
6464
})
6565

6666
test('should parse id from resource without explicit ns', t => {
@@ -84,14 +84,14 @@ test('should parse id from resource with explicit ns and package but missing lea
8484
})
8585

8686
test('should throw error parsing id with only namespace', t => {
87-
t.throws(() => names.parseId('/ns'), /Invalid resource identifier/)
87+
t.throws(() => names.parseId('/ns'), { message: /Invalid resource identifier/ })
8888
})
8989

9090
test('should throw error parsing id with only extra paths', t => {
91-
t.throws(() => names.parseId('/ns/pkg/action/extra'), /Invalid resource identifier/)
92-
t.throws(() => names.parseId('ns/pkg/action/extra'), /Invalid resource identifier/)
91+
t.throws(() => names.parseId('/ns/pkg/action/extra'), { message: /Invalid resource identifier/ })
92+
t.throws(() => names.parseId('ns/pkg/action/extra'), { message: /Invalid resource identifier/ })
9393
})
9494

9595
test('should throw error parsing id with missing parts', t => {
96-
t.throws(() => names.parseId('/'), /Invalid resource identifier/)
96+
t.throws(() => names.parseId('/'), { message: /Invalid resource identifier/ })
9797
})

test/unit/packages.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ test('should delete package from identifier', t => {
135135

136136
test('should throw error trying to invoke package', t => {
137137
const packages = new Packages()
138-
return t.throws(() => packages.invoke(), /Operation \(invoke\) not supported/)
138+
return t.throws(() => packages.invoke(), { message: /Operation \(invoke\) not supported/ })
139139
})
140140

141141
test('should create a new package using string id', t => {

test/unit/resources.test.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,11 @@ test('should send multiple requests for array parameters', t => {
172172
test('should throw errors when missing resource identifier', t => {
173173
const resources = new Resources()
174174

175-
t.throws(() => resources.get(), /Missing resource identifier from parameters, supported parameter names: name/)
176-
t.throws(() => resources.invoke(), /Missing resource identifier from parameters, supported parameter names: name/)
177-
t.throws(() => resources.create(), /Missing resource identifier from parameters, supported parameter names: name/)
178-
t.throws(() => resources.update({}), /Missing resource identifier from parameters, supported parameter names: name/)
179-
t.throws(() => resources.delete(), /Missing resource identifier from parameters, supported parameter names: name/)
175+
t.throws(() => resources.get(), { message: /Missing resource identifier from parameters, supported parameter names: name/ })
176+
t.throws(() => resources.invoke(), { message: /Missing resource identifier from parameters, supported parameter names: name/ })
177+
t.throws(() => resources.create(), { message: /Missing resource identifier from parameters, supported parameter names: name/ })
178+
t.throws(() => resources.update({}), { message: /Missing resource identifier from parameters, supported parameter names: name/ })
179+
t.throws(() => resources.delete(), { message: /Missing resource identifier from parameters, supported parameter names: name/ })
180180
})
181181

182182
test('should parse action name from identifier', t => {
@@ -188,7 +188,7 @@ test('should parse action name from identifier', t => {
188188
t.is(resources.parseId({ name: id }), id)
189189
t.is(resources.parseId({ name: nsId }), id)
190190
t.is(resources.parseId({ name: nsPackageId }), `package/12345`)
191-
t.throws(() => resources.parseId({ name: '/ns' }), /Invalid resource/)
191+
t.throws(() => resources.parseId({ name: '/ns' }), { message: /Invalid resource/ })
192192
})
193193

194194
test('should parse namespace from identifier and options', t => {

test/unit/routes.test.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ test('should retrieve routes with apigwToken and basepath', t => {
8484

8585
test('get routes with incorrect parameters', t => {
8686
const routes = new Routes({ options: {} })
87-
t.throws(() => { routes.get() }, /Missing mandatory parameters: basepath or name/)
88-
t.throws(() => { routes.get({}) }, /Missing mandatory parameters: basepath or name/)
89-
t.throws(() => { routes.get({ basepath: 'id', name: 'id' }) }, /Invalid parameters: use basepath or name, not both/)
87+
t.throws(() => { routes.get() }, { message: /Missing mandatory parameters: basepath or name/ })
88+
t.throws(() => { routes.get({}) }, { message: /Missing mandatory parameters: basepath or name/ })
89+
t.throws(() => { routes.get({ basepath: 'id', name: 'id' }) }, { message: /Invalid parameters: use basepath or name, not both/ })
9090
})
9191

9292
// OVERRIDE gateway package
@@ -172,7 +172,7 @@ test('list routes providing basepath and name', t => {
172172
basepath: 'bp',
173173
name: 'nm'
174174
})
175-
}, /Invalid parameters: use basepath or name, not both/)
175+
}, { message: /Invalid parameters: use basepath or name, not both/ })
176176
})
177177

178178
test('should delete a route with basepath', t => {
@@ -242,7 +242,7 @@ test('should delete a route with parameters', t => {
242242
test('delete routes without providing basepath or name', t => {
243243
const client = { options: {} }
244244
const routes = new Routes(client)
245-
return t.throws(() => { routes.delete() }, /Missing mandatory parameters: basepath or name/)
245+
return t.throws(() => { routes.delete() }, { message: /Missing mandatory parameters: basepath or name/ })
246246
})
247247

248248
test('delete routes providing basepath and name', t => {
@@ -253,7 +253,7 @@ test('delete routes providing basepath and name', t => {
253253
basepath: 'bp',
254254
name: 'nm'
255255
})
256-
}, /Invalid parameters: use basepath or name, not both/)
256+
}, { message: /Invalid parameters: use basepath or name, not both/ })
257257
})
258258

259259
test('should create a route', t => {
@@ -763,8 +763,8 @@ test('should parse path parameters', t => {
763763

764764
test('create routes missing mandatory parameters', t => {
765765
const routes = new Routes()
766-
t.throws(() => { routes.create() }, /Missing mandatory parameters: relpath, operation, action/)
767-
t.throws(() => { routes.create({ relpath: true, operation: true }) }, /Missing mandatory parameters: action/)
768-
t.throws(() => { routes.create({ action: true, operation: true }) }, /Missing mandatory parameters: relpath/)
769-
t.throws(() => { routes.create({ relpath: true, action: true }) }, /Missing mandatory parameters: operation/)
766+
t.throws(() => { routes.create() }, { message: /Missing mandatory parameters: relpath, operation, action/ })
767+
t.throws(() => { routes.create({ relpath: true, operation: true }) }, { message: /Missing mandatory parameters: action/ })
768+
t.throws(() => { routes.create({ action: true, operation: true }) }, { message: /Missing mandatory parameters: relpath/ })
769+
t.throws(() => { routes.create({ relpath: true, action: true }) }, { message: /Missing mandatory parameters: operation/ })
770770
})

test/unit/rules.test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ test('should delete rule from string identifier', t => {
135135

136136
test('should throw error trying to invoke rule', t => {
137137
const rules = new Rules()
138-
return t.throws(() => rules.invoke(), /Operation \(invoke\) not supported/)
138+
return t.throws(() => rules.invoke(), { message: /Operation \(invoke\) not supported/ })
139139
})
140140

141141
test('create a new rule', t => {
@@ -211,21 +211,21 @@ test('create a rule without providing a rule name', t => {
211211
const rules = new Rules(client)
212212
return t.throws(() => {
213213
rules.create({ action: '', trigger: '' })
214-
}, /name, ruleName/)
214+
}, { message: /name, ruleName/ })
215215
})
216216

217217
test('create a rule without providing an action name', t => {
218218
const rules = new Rules()
219219
return t.throws(() => {
220220
rules.create({ name: '', trigger: '' })
221-
}, /Missing mandatory action parameter/)
221+
}, { message: /Missing mandatory action parameter/ })
222222
})
223223

224224
test('create a rule without providing a trigger name', t => {
225225
const rules = new Rules()
226226
return t.throws(() => {
227227
rules.create({ name: '', action: '' })
228-
}, /Missing mandatory trigger parameter/)
228+
}, { message: /Missing mandatory trigger parameter/ })
229229
})
230230

231231
test('update existing rule', t => {

0 commit comments

Comments
 (0)