Skip to content

Commit

Permalink
chore tap 15 (#3)
Browse files Browse the repository at this point in the history
* wax in action

* fix ci

* fix test

* 100 coverage check
  • Loading branch information
Eomm authored Apr 22, 2021
1 parent b2cba83 commit 9445cdd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 35 deletions.
24 changes: 0 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ on:
- "docs/**"
- "*.md"

env:
CI: true
COVERALLS: 0

jobs:
build:
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -40,23 +36,3 @@ jobs:
- name: Tests
id: test
run: npm run test

- name: Coveralls Parallel
id: coveralls
uses: coverallsapp/github-action@master
if: env.COVERALLS == 1
with:
github-token: ${{ secrets.github_token }}
parallel: true

coverage:
needs: build
runs-on: ubuntu-latest
if: env.COVERALLS == 1
steps:
- name: Coveralls Finished
id: send_coveralls_report
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
"ajv-errors": "^1.0.1",
"ajv-merge-patch": "^4.1.0",
"standard": "^16.0.3",
"tap": "^14.11.0"
"tap": "^15.0.1"
},
"dependencies": {
"ajv": "^6.12.6"
}
}
}
18 changes: 9 additions & 9 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ t.test('basic usage', t => {
const compiler = factory(externalSchemas1, fastifyAjvOptionsDefault)
const validatorFunc = compiler({ schema: sampleSchema })
const result = validatorFunc({ name: 'hello' })
t.equals(result, true)
t.equal(result, true)
})

t.test('plugin loading', t => {
Expand All @@ -69,27 +69,27 @@ t.test('plugin loading', t => {
}
})
const result = validatorFunc({ q: 'hello' })
t.equals(result, true)
t.equal(result, true)

const resultFail = validatorFunc({ })
t.equals(resultFail, false)
t.equals(validatorFunc.errors[0].message, 'hello world')
t.equal(resultFail, false)
t.equal(validatorFunc.errors[0].message, 'hello world')
})

t.test('optimization - cache ajv instance', t => {
t.plan(5)
const factory = AjvCompiler()
const compiler1 = factory(externalSchemas1, fastifyAjvOptionsDefault)
const compiler2 = factory(externalSchemas1, fastifyAjvOptionsDefault)
t.equals(compiler1, compiler2, 'same instance')
t.deepEquals(compiler1, compiler2, 'same instance')
t.equal(compiler1, compiler2, 'same instance')
t.same(compiler1, compiler2, 'same instance')

const compiler3 = factory(externalSchemas2, fastifyAjvOptionsDefault)
t.notEqual(compiler3, compiler1, 'new ajv instance when externa schema change')
t.not(compiler3, compiler1, 'new ajv instance when externa schema change')

const compiler4 = factory(externalSchemas1, fastifyAjvOptionsCustom)
t.notEqual(compiler4, compiler1, 'new ajv instance when externa schema change')
t.notEqual(compiler4, compiler3, 'new ajv instance when externa schema change')
t.not(compiler4, compiler1, 'new ajv instance when externa schema change')
t.not(compiler4, compiler3, 'new ajv instance when externa schema change')
})

// https://github.com/fastify/fastify/pull/2969
Expand Down

0 comments on commit 9445cdd

Please sign in to comment.