Skip to content
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
1 change: 1 addition & 0 deletions .taprc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
check-coverage: false
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"pre-commit": "^1.2.2",
"rimraf": "^3.0.2",
"standard": "^16.0.1",
"tap": "^14.0.0",
"tap": "^15.0.2",
"tsd": "^0.14.0",
"typescript": "^4.0.2"
},
Expand Down
18 changes: 9 additions & 9 deletions test/example-async.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const build = require('../example-async')
let fastify = null
let token = null

t.tearDown(() => {
t.teardown(() => {
fastify.close()
rimraf('./authdb', err => {
if (err) throw err
Expand All @@ -32,7 +32,7 @@ test('Route without auth', t => {
}, (err, res) => {
t.error(err)
const payload = JSON.parse(res.payload)
t.deepEqual(payload, { hello: 'world' })
t.same(payload, { hello: 'world' })
})
})

Expand All @@ -46,7 +46,7 @@ test('Missing header', t => {
}, (err, res) => {
t.error(err)
const payload = JSON.parse(res.payload)
t.deepEqual(payload, {
t.same(payload, {
error: 'Unauthorized',
message: 'Missing token header',
statusCode: 401
Expand All @@ -69,7 +69,7 @@ test('Register user', t => {
const payload = JSON.parse(res.payload)
t.equal(res.statusCode, 200)
token = payload.token
t.is(typeof payload.token, 'string')
t.equal(typeof payload.token, 'string')
})
})

Expand All @@ -85,7 +85,7 @@ test('Auth succesful', t => {
}, (err, res) => {
t.error(err)
const payload = JSON.parse(res.payload)
t.deepEqual(payload, { hello: 'world' })
t.same(payload, { hello: 'world' })
})
})

Expand All @@ -102,7 +102,7 @@ test('Auth succesful (multiple)', t => {
}, (err, res) => {
t.error(err)
const payload = JSON.parse(res.payload)
t.deepEqual(payload, { hello: 'world' })
t.same(payload, { hello: 'world' })
})
})

Expand All @@ -118,7 +118,7 @@ test('Auth not succesful', t => {
}, (err, res) => {
t.error(err)
const payload = JSON.parse(res.payload)
t.deepEqual(payload, {
t.same(payload, {
error: 'Unauthorized',
message: 'Token not valid',
statusCode: 401
Expand All @@ -139,7 +139,7 @@ test('Auth not succesful (multiple)', t => {
}, (err, res) => {
t.error(err)
const payload = JSON.parse(res.payload)
t.deepEqual(payload, {
t.same(payload, {
error: 'Unauthorized',
message: 'Password not valid',
statusCode: 401
Expand All @@ -162,6 +162,6 @@ test('Failure with explicit reply', t => {
t.error(err)
const payload = JSON.parse(res.payload)
t.equal(res.statusCode, 401)
t.deepEqual(payload, { error: 'Unauthorized' })
t.same(payload, { error: 'Unauthorized' })
})
})
54 changes: 27 additions & 27 deletions test/example-composited.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const build = require('../example-composited')

let fastify = null

t.tearDown(() => {
t.teardown(() => {
fastify.close()
})

Expand All @@ -28,7 +28,7 @@ test('And Relation sucess for single case', t => {
}, (err, res) => {
t.error(err)
const payload = JSON.parse(res.payload)
t.deepEqual(payload, { hello: 'world' })
t.same(payload, { hello: 'world' })
})
})

Expand All @@ -44,7 +44,7 @@ test('And Relation failed for single case', t => {
}, (err, res) => {
t.error(err)
const payload = JSON.parse(res.payload)
t.deepEqual(payload, {
t.same(payload, {
error: 'Unauthorized',
message: '`n` is not odd',
statusCode: 401
Expand All @@ -64,7 +64,7 @@ test('Or Relation sucess for single case', t => {
}, (err, res) => {
t.error(err)
const payload = JSON.parse(res.payload)
t.deepEqual(payload, { hello: 'world' })
t.same(payload, { hello: 'world' })
})
})

Expand All @@ -80,7 +80,7 @@ test('Or Relation failed for single case', t => {
}, (err, res) => {
t.error(err)
const payload = JSON.parse(res.payload)
t.deepEqual(payload, {
t.same(payload, {
error: 'Unauthorized',
message: '`n` is not odd',
statusCode: 401
Expand All @@ -100,7 +100,7 @@ test('And Relation failed for first check', t => {
}, (err, res) => {
t.error(err)
const payload = JSON.parse(res.payload)
t.deepEqual(payload, {
t.same(payload, {
error: 'Unauthorized',
message: 'type of `n` is not `number`',
statusCode: 401
Expand All @@ -120,7 +120,7 @@ test('And Relation failed for first check', t => {
}, (err, res) => {
t.error(err)
const payload = JSON.parse(res.payload)
t.deepEqual(payload, {
t.same(payload, {
error: 'Unauthorized',
message: 'type of `n` is not `number`',
statusCode: 401
Expand All @@ -140,7 +140,7 @@ test('And Relation failed for second check', t => {
}, (err, res) => {
t.error(err)
const payload = JSON.parse(res.payload)
t.deepEqual(payload, {
t.same(payload, {
error: 'Unauthorized',
message: '`n` is not odd',
statusCode: 401
Expand All @@ -160,7 +160,7 @@ test('And Relation success', t => {
}, (err, res) => {
t.error(err)
const payload = JSON.parse(res.payload)
t.deepEqual(payload, { hello: 'world' })
t.same(payload, { hello: 'world' })
t.equal(res.statusCode, 200)
})
})
Expand All @@ -177,7 +177,7 @@ test('Or Relation success under first case', t => {
}, (err, res) => {
t.error(err)
const payload = JSON.parse(res.payload)
t.deepEqual(payload, { hello: 'world' })
t.same(payload, { hello: 'world' })
t.equal(res.statusCode, 200)
})
})
Expand All @@ -194,7 +194,7 @@ test('Or Relation success under second case', t => {
}, (err, res) => {
t.error(err)
const payload = JSON.parse(res.payload)
t.deepEqual(payload, { hello: 'world' })
t.same(payload, { hello: 'world' })
t.equal(res.statusCode, 200)
})
})
Expand All @@ -211,7 +211,7 @@ test('Or Relation failed for both case', t => {
}, (err, res) => {
t.error(err)
const payload = JSON.parse(res.payload)
t.deepEqual(payload, {
t.same(payload, {
error: 'Unauthorized',
message: '`n` is not big',
statusCode: 401
Expand Down Expand Up @@ -241,9 +241,9 @@ test('Check run all line fail with AND', t => {

fastify.inject('/run-all-pipe', (err, res) => {
t.error(err)
t.equals(res.statusCode, 401)
t.equal(res.statusCode, 401)
const payload = JSON.parse(res.payload)
t.deepEqual(payload, {
t.same(payload, {
error: 'Unauthorized',
message: 'second',
statusCode: 401
Expand Down Expand Up @@ -273,9 +273,9 @@ test('Check run all line with AND', t => {

fastify.inject('/run-all-pipe', (err, res) => {
t.error(err)
t.equals(res.statusCode, 200)
t.equal(res.statusCode, 200)
const payload = JSON.parse(res.payload)
t.deepEqual(payload, { hello: 'world' })
t.same(payload, { hello: 'world' })
})
})

Expand All @@ -301,9 +301,9 @@ test('Check run all line with OR', t => {

fastify.inject('/run-all-pipe', (err, res) => {
t.error(err)
t.equals(res.statusCode, 200)
t.equal(res.statusCode, 200)
const payload = JSON.parse(res.payload)
t.deepEqual(payload, { hello: 'world' })
t.same(payload, { hello: 'world' })
})
})

Expand All @@ -329,9 +329,9 @@ test('Check run all fail line with OR', t => {

fastify.inject('/run-all-pipe', (err, res) => {
t.error(err)
t.equals(res.statusCode, 401)
t.equal(res.statusCode, 401)
const payload = JSON.parse(res.payload)
t.deepEqual(payload, {
t.same(payload, {
error: 'Unauthorized',
message: 'quinto',
statusCode: 401
Expand All @@ -358,9 +358,9 @@ test('Ignore last status', t => {

fastify.inject('/run-all-status', (err, res) => {
t.error(err)
t.equals(res.statusCode, 200)
t.equal(res.statusCode, 200)
const payload = JSON.parse(res.payload)
t.deepEqual(payload, { hello: 'world' })
t.same(payload, { hello: 'world' })
})
})

Expand All @@ -376,7 +376,7 @@ test('Or Relation run all', t => {
}, (err, res) => {
t.error(err)
const payload = JSON.parse(res.payload)
t.deepEqual(payload, {
t.same(payload, {
odd: true,
big: false,
number: true
Expand All @@ -396,7 +396,7 @@ test('Or Relation run all fail', t => {
}, (err, res) => {
t.error(err)
const payload = JSON.parse(res.payload)
t.deepEqual(payload, {
t.same(payload, {
error: 'Unauthorized',
message: 'type of `n` is not `number`',
statusCode: 401
Expand All @@ -416,7 +416,7 @@ test('And Relation run all', t => {
}, (err, res) => {
t.error(err)
const payload = JSON.parse(res.payload)
t.deepEqual(payload, {
t.same(payload, {
odd: true,
big: true,
number: true
Expand All @@ -443,8 +443,8 @@ test('Clean status code settle by user', t => {

fastify.inject('/run-all-status', (err, res) => {
t.error(err)
t.equals(res.statusCode, 200)
t.equal(res.statusCode, 200)
const payload = JSON.parse(res.payload)
t.deepEqual(payload, { hello: 'world' })
t.same(payload, { hello: 'world' })
})
})
18 changes: 9 additions & 9 deletions test/example.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const build = require('../example')
let fastify = null
let token = null

t.tearDown(() => {
t.teardown(() => {
fastify.close()
rimraf('./authdb', err => {
if (err) throw err
Expand All @@ -32,7 +32,7 @@ test('Route without auth', t => {
}, (err, res) => {
t.error(err)
const payload = JSON.parse(res.payload)
t.deepEqual(payload, { hello: 'world' })
t.same(payload, { hello: 'world' })
})
})

Expand All @@ -46,7 +46,7 @@ test('Missing header', t => {
}, (err, res) => {
t.error(err)
const payload = JSON.parse(res.payload)
t.deepEqual(payload, {
t.same(payload, {
error: 'Unauthorized',
message: 'Missing token header',
statusCode: 401
Expand All @@ -69,7 +69,7 @@ test('Register user', t => {
const payload = JSON.parse(res.payload)
t.equal(res.statusCode, 200)
token = payload.token
t.is(typeof payload.token, 'string')
t.equal(typeof payload.token, 'string')
})
})

Expand All @@ -85,7 +85,7 @@ test('Auth succesful', t => {
}, (err, res) => {
t.error(err)
const payload = JSON.parse(res.payload)
t.deepEqual(payload, { hello: 'world' })
t.same(payload, { hello: 'world' })
})
})

Expand All @@ -101,7 +101,7 @@ test('Auth not succesful', t => {
}, (err, res) => {
t.error(err)
const payload = JSON.parse(res.payload)
t.deepEqual(payload, {
t.same(payload, {
error: 'Unauthorized',
message: 'Token not valid',
statusCode: 401
Expand All @@ -122,7 +122,7 @@ test('Auth succesful (multiple)', t => {
}, (err, res) => {
t.error(err)
const payload = JSON.parse(res.payload)
t.deepEqual(payload, { hello: 'world' })
t.same(payload, { hello: 'world' })
})
})

Expand All @@ -139,7 +139,7 @@ test('Auth not succesful (multiple)', t => {
}, (err, res) => {
t.error(err)
const payload = JSON.parse(res.payload)
t.deepEqual(payload, {
t.same(payload, {
error: 'Unauthorized',
message: 'Password not valid',
statusCode: 401
Expand All @@ -162,6 +162,6 @@ test('Failure with explicit reply', t => {
t.error(err)
const payload = JSON.parse(res.payload)
t.equal(res.statusCode, 401)
t.deepEqual(payload, { error: 'Unauthorized' })
t.same(payload, { error: 'Unauthorized' })
})
})