Skip to content

Commit

Permalink
update ava dependency from 2.1.0 to 5.3.0 (#266)
Browse files Browse the repository at this point in the history
* update ava dependency from 2.1.0 to 5.3.0
* update used of throws to always pass expectation object
  • Loading branch information
dgrove-oss authored Nov 28, 2023
1 parent d461a21 commit 40e9f2d
Show file tree
Hide file tree
Showing 11 changed files with 1,623 additions and 5,269 deletions.
6,798 changes: 1,576 additions & 5,222 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "lib/main.js",
"typings": "lib/main.d.ts",
"engines": {
"node": ">=6.0.0"
"node": ">=18.0.0"
},
"directories": {
"test": "tests"
Expand Down Expand Up @@ -41,7 +41,7 @@
"devDependencies": {
"@types/node": "^12.0.10",
"@types/swagger-schema-official": "^2.0.17",
"ava": "^2.1.0",
"ava": "^5.3.0",
"codecov": "^3.5.0",
"jszip": "^3.1.3",
"nock": "^11.7.0",
Expand Down
10 changes: 5 additions & 5 deletions test/unit/actions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ test('create a new action with concurrency setting', t => {

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

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

const actions = new Actions(client)

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

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

const actions = new Actions(client)

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

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

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

test('should pass through requested User-Agent header', t => {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/activations.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,5 +197,5 @@ test('should throw when retrieving activation without id', t => {
const activations = new Activations()
return t.throws(() => {
activations.get()
}, /Missing mandatory/)
}, { message: /Missing mandatory/ })
})
16 changes: 8 additions & 8 deletions test/unit/client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,11 @@ test('should use options for parameters even if environment parameters are avail
})

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

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

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

test('should return response error string in error message', t => {
Expand All @@ -415,27 +415,27 @@ test('should return response error string in error message', t => {
error: { error: 'hello' },
options: { method, url },
statusCode
}), `${method} ${url} Returned HTTP ${statusCode} (${http.STATUS_CODES[statusCode]}) --> "hello"`)
}), { message: `${method} ${url} Returned HTTP ${statusCode} (${http.STATUS_CODES[statusCode]}) --> "hello"` })
t.throws(() => client.handleErrors({
error: { response: { result: { error: 'hello' } } },
options: { method, url },
statusCode
}), `${method} ${url} Returned HTTP ${statusCode} (${http.STATUS_CODES[statusCode]}) --> "hello"`)
}), { message: `${method} ${url} Returned HTTP ${statusCode} (${http.STATUS_CODES[statusCode]}) --> "hello"` })
t.throws(() => client.handleErrors({
error: { response: { result: { error: { error: 'hello' } } } },
options: { method, url },
statusCode
}), `${method} ${url} Returned HTTP ${statusCode} (${http.STATUS_CODES[statusCode]}) --> "hello"`)
}), { message: `${method} ${url} Returned HTTP ${statusCode} (${http.STATUS_CODES[statusCode]}) --> "hello"` })
t.throws(() => client.handleErrors({
error: { response: { result: { error: { statusCode: 404 } } } },
options: { method, url },
statusCode
}), `${method} ${url} Returned HTTP ${statusCode} (${http.STATUS_CODES[statusCode]}) --> "application error, status code: ${404}"`)
}), { message: `${method} ${url} Returned HTTP ${statusCode} (${http.STATUS_CODES[statusCode]}) --> "application error, status code: ${404}"` })
})

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

test('should contain x-namespace-id header when namespace in constructor options', async t => {
Expand Down
4 changes: 2 additions & 2 deletions test/unit/feeds.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,11 @@ test('should be able to update feed', t => {
test('should throw errors without trigger parameter ', t => {
const client = { options: {} }
const feeds = new Feeds(client)
t.throws(() => feeds.feed('', { feedName: 'myFeed' }), /trigger/)
t.throws(() => feeds.feed('', { feedName: 'myFeed' }), { message: /trigger/ })
})

test('should throw errors without id parameter', t => {
const client = { options: {} }
const feeds = new Feeds(client)
t.throws(() => feeds.feed('', { trigger: 'myFeed' }), /feedName/)
t.throws(() => feeds.feed('', { trigger: 'myFeed' }), { message: /feedName/ })
})
16 changes: 8 additions & 8 deletions test/unit/names.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ test('should parse namespace from resource with explicit ns and package but miss
})

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

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

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

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

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

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

test('should throw error parsing id with missing parts', t => {
t.throws(() => names.parseId('/'), /Invalid resource identifier/)
t.throws(() => names.parseId('/'), { message: /Invalid resource identifier/ })
})
2 changes: 1 addition & 1 deletion test/unit/packages.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ test('should delete package from identifier', t => {

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

test('should create a new package using string id', t => {
Expand Down
12 changes: 6 additions & 6 deletions test/unit/resources.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,11 @@ test('should send multiple requests for array parameters', t => {
test('should throw errors when missing resource identifier', t => {
const resources = new Resources()

t.throws(() => resources.get(), /Missing resource identifier from parameters, supported parameter names: name/)
t.throws(() => resources.invoke(), /Missing resource identifier from parameters, supported parameter names: name/)
t.throws(() => resources.create(), /Missing resource identifier from parameters, supported parameter names: name/)
t.throws(() => resources.update({}), /Missing resource identifier from parameters, supported parameter names: name/)
t.throws(() => resources.delete(), /Missing resource identifier from parameters, supported parameter names: name/)
t.throws(() => resources.get(), { message: /Missing resource identifier from parameters, supported parameter names: name/ })
t.throws(() => resources.invoke(), { message: /Missing resource identifier from parameters, supported parameter names: name/ })
t.throws(() => resources.create(), { message: /Missing resource identifier from parameters, supported parameter names: name/ })
t.throws(() => resources.update({}), { message: /Missing resource identifier from parameters, supported parameter names: name/ })
t.throws(() => resources.delete(), { message: /Missing resource identifier from parameters, supported parameter names: name/ })
})

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

test('should parse namespace from identifier and options', t => {
Expand Down
20 changes: 10 additions & 10 deletions test/unit/routes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ test('should retrieve routes with apigwToken and basepath', t => {

test('get routes with incorrect parameters', t => {
const routes = new Routes({ options: {} })
t.throws(() => { routes.get() }, /Missing mandatory parameters: basepath or name/)
t.throws(() => { routes.get({}) }, /Missing mandatory parameters: basepath or name/)
t.throws(() => { routes.get({ basepath: 'id', name: 'id' }) }, /Invalid parameters: use basepath or name, not both/)
t.throws(() => { routes.get() }, { message: /Missing mandatory parameters: basepath or name/ })
t.throws(() => { routes.get({}) }, { message: /Missing mandatory parameters: basepath or name/ })
t.throws(() => { routes.get({ basepath: 'id', name: 'id' }) }, { message: /Invalid parameters: use basepath or name, not both/ })
})

// OVERRIDE gateway package
Expand Down Expand Up @@ -172,7 +172,7 @@ test('list routes providing basepath and name', t => {
basepath: 'bp',
name: 'nm'
})
}, /Invalid parameters: use basepath or name, not both/)
}, { message: /Invalid parameters: use basepath or name, not both/ })
})

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

test('delete routes providing basepath and name', t => {
Expand All @@ -253,7 +253,7 @@ test('delete routes providing basepath and name', t => {
basepath: 'bp',
name: 'nm'
})
}, /Invalid parameters: use basepath or name, not both/)
}, { message: /Invalid parameters: use basepath or name, not both/ })
})

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

test('create routes missing mandatory parameters', t => {
const routes = new Routes()
t.throws(() => { routes.create() }, /Missing mandatory parameters: relpath, operation, action/)
t.throws(() => { routes.create({ relpath: true, operation: true }) }, /Missing mandatory parameters: action/)
t.throws(() => { routes.create({ action: true, operation: true }) }, /Missing mandatory parameters: relpath/)
t.throws(() => { routes.create({ relpath: true, action: true }) }, /Missing mandatory parameters: operation/)
t.throws(() => { routes.create() }, { message: /Missing mandatory parameters: relpath, operation, action/ })
t.throws(() => { routes.create({ relpath: true, operation: true }) }, { message: /Missing mandatory parameters: action/ })
t.throws(() => { routes.create({ action: true, operation: true }) }, { message: /Missing mandatory parameters: relpath/ })
t.throws(() => { routes.create({ relpath: true, action: true }) }, { message: /Missing mandatory parameters: operation/ })
})
8 changes: 4 additions & 4 deletions test/unit/rules.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ test('should delete rule from string identifier', t => {

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

test('create a new rule', t => {
Expand Down Expand Up @@ -211,21 +211,21 @@ test('create a rule without providing a rule name', t => {
const rules = new Rules(client)
return t.throws(() => {
rules.create({ action: '', trigger: '' })
}, /name, ruleName/)
}, { message: /name, ruleName/ })
})

test('create a rule without providing an action name', t => {
const rules = new Rules()
return t.throws(() => {
rules.create({ name: '', trigger: '' })
}, /Missing mandatory action parameter/)
}, { message: /Missing mandatory action parameter/ })
})

test('create a rule without providing a trigger name', t => {
const rules = new Rules()
return t.throws(() => {
rules.create({ name: '', action: '' })
}, /Missing mandatory trigger parameter/)
}, { message: /Missing mandatory trigger parameter/ })
})

test('update existing rule', t => {
Expand Down

0 comments on commit 40e9f2d

Please sign in to comment.