Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error code of AVV_ERR_ROOT_PLG_BOOTED #206

Merged
merged 3 commits into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ module.exports = {
"Plugin must be a function or a promise. Received: '%s'"
),
AVV_ERR_ROOT_PLG_BOOTED: createError(
'AVV_ERR_PLUGIN_NOT_VALID',
'AVV_ERR_ROOT_PLG_BOOTED',
'Root plugin has already booted'
),
AVV_ERR_PARENT_PLG_LOADED: createError(
Expand Down
23 changes: 22 additions & 1 deletion test/errors.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
'use strict'

const { test } = require('tap')
const { createError } = require('../lib/errors')
const errors = require('../lib/errors')
const createError = errors.createError

const expectedErrorName = 'AvvioError'

Expand Down Expand Up @@ -96,3 +97,23 @@ test('Create the error without the new keyword', t => {
t.equal(err.message, 'Not available')
t.equal(err.code, 'CODE')
})

test('Correct codes of AvvioErrors', t => {
const testcases = [
'AVV_ERR_EXPOSE_ALREADY_DEFINED',
'AVV_ERR_CALLBACK_NOT_FN',
'AVV_ERR_PLUGIN_NOT_VALID',
'AVV_ERR_ROOT_PLG_BOOTED',
'AVV_ERR_PARENT_PLG_LOADED',
'AVV_ERR_READY_TIMEOUT'
]

t.plan(testcases.length + 1)
// errors.js exposes errors and the createError fn
t.equal(testcases.length + 1, Object.keys(errors).length)

for (const testcase of testcases) {
const error = new errors[testcase]()
t.equal(error.code, testcase)
}
})