Skip to content

Commit

Permalink
test against hapi 18 and 19
Browse files Browse the repository at this point in the history
  • Loading branch information
jscheffner committed Apr 12, 2020
1 parent 0324b49 commit 25beae7
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
15 changes: 14 additions & 1 deletion .github/workflows/nodejs.yml
Expand Up @@ -5,7 +5,20 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [8.x, 10.x, 12.x]
node-version:
- 8.x
- 10.x
- 12.x
hapi-version:
- 18
- 19
exclude:
- node-version: 8.x
hapi-version: 19
- node-version: 10.x
hapi-version: 19
env:
HAPI_VERSION: ${{ matrix.hapi-version }}
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/publish.yml
Expand Up @@ -14,6 +14,7 @@ jobs:
node-version: 12
- run: npm install
- run: npm test
- run: npm run test:hapi19

publish-npm:
needs: build
Expand Down
5 changes: 4 additions & 1 deletion package.json
Expand Up @@ -5,6 +5,7 @@
"main": "index.js",
"scripts": {
"test": "nyc ava",
"test:hapi19": "cross-env HAPI_VERSION=19 nyc ava",
"lint": "eslint test index.js test/**/*.js examples/**/*.js",
"format": "npm run lint -- --fix",
"coverage": "nyc report --reporter=text-lcov | coveralls"
Expand Down Expand Up @@ -34,13 +35,15 @@
"license": "ISC",
"devDependencies": {
"@hapi/hapi": "^18.3.1",
"ava": "^3.1.0",
"ava": "^2.4.0",
"coveralls": "^3.0.6",
"cross-env": "^6.0.3",
"eslint": "^5.3.0",
"eslint-config-airbnb": "^17.1.1",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.14.3",
"hapi19": "npm:@hapi/hapi@^19.0.5",
"nyc": "^15.0.0"
},
"ava": {
Expand Down
17 changes: 6 additions & 11 deletions test/index.spec.js
Expand Up @@ -3,11 +3,6 @@ const { AggregateError } = require('p-any');
const { isBoom } = require('@hapi/boom');
const { setup: setupAll, setupServerAndPlugin, request } = require('./utils');

test('register plugin and create strategy', async (t) => {
const server = await setupServerAndPlugin();
t.is(typeof server.auth._schemes.any, 'function');
});

test('fail if all fail', async (t) => {
const server = await setupAll([false, false, false]);
const { statusCode, result } = await request(server);
Expand All @@ -25,13 +20,13 @@ test('provide causes of failing strategies', async (t) => {
});

request(server);
const err = await listener;
const errors = await listener;

t.log(err);
t.true(err instanceof AggregateError);
t.true(isBoom(err));
t.is([...err].length, 4);
t.true([...err].every(isBoom));
t.log(errors);
t.true(errors instanceof AggregateError);
t.true(isBoom(errors));
t.is([...errors].length, 4);
[...errors].forEach(err => t.true(isBoom(err), `${err.strategy} should result in a boom error.`));
});

test('succeed if all succeed', async (t) => {
Expand Down
3 changes: 2 additions & 1 deletion test/utils.js
@@ -1,4 +1,5 @@
const hapi = require('@hapi/hapi');
// eslint-disable-next-line import/no-dynamic-require
const hapi = require(process.env.HAPI_VERSION === '19' ? 'hapi19' : '@hapi/hapi');
const boom = require('@hapi/boom');
const anyAuth = require('../');

Expand Down

0 comments on commit 25beae7

Please sign in to comment.