Skip to content

Commit

Permalink
fix eslint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
epoberezkin committed Dec 6, 2020
1 parent b823062 commit 8e2248c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/standalone/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function standaloneCode(
if (!ajv.opts.code.source) {
throw new Error("moduleCode: ajv instance must have code.source option")
}
const _n = ajv.scope.opts._n
const {_n} = ajv.scope.opts
return typeof refsOrFunc == "function"
? funcExportCode(refsOrFunc.source)
: refsOrFunc !== undefined
Expand Down
22 changes: 15 additions & 7 deletions spec/after_test.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
import type Ajv from ".."
import type {AnySchema, ErrorObject} from ".."
import chai from "./chai"
const should = chai.should()

module.exports = {
error: afterError,
each: afterEach,
interface TestResult {
validator: Ajv
schema: AnySchema
data: unknown
valid: boolean
expected: boolean
errors: ErrorObject[] | null
passed: boolean // true if valid == expected
}

export function afterError(res): void {
export function afterError(res: TestResult): void {
console.log("ajv options:", res.validator.opts)
}

export function afterEach(res): void {
export function afterEach(res: TestResult): void {
// console.log(res.errors);
res.valid.should.be.a("boolean")
if (res.valid === true) {
should.equal(res.errors, null)
} else {
res.errors.should.be.an("array")
for (const err of res.errors) {
const errs = res.errors as ErrorObject[]
errs.should.be.an("array")
for (const err of errs) {
err.should.be.an("object")
}
}
Expand Down

0 comments on commit 8e2248c

Please # to comment.