Chapter 11: update example microservice

This commit is contained in:
Beth Griggs
2020-11-15 01:11:41 +00:00
parent 791aac76d7
commit cb0e52e541
11 changed files with 146 additions and 9 deletions
@@ -0,0 +1,27 @@
'use strict'
const { test } = require('tap')
const { build } = require('../helper')
test('example is loaded', async (t) => {
const app = build(t)
const res = await app.inject({
url: '/example'
})
t.equal(res.payload, 'this is an example')
})
// inject callback style:
//
// test('example is loaded', (t) => {
// t.plan(2)
// const app = build(t)
//
// app.inject({
// url: '/example'
// }, (err, res) => {
// t.error(err)
// t.equal(res.payload, 'this is an example')
// })
// })
@@ -0,0 +1,27 @@
'use strict'
const { test } = require('tap')
const { build } = require('../helper')
test('default root route', async (t) => {
const app = build(t)
const res = await app.inject({
url: '/'
})
t.deepEqual(JSON.parse(res.payload), { root: true })
})
// inject callback style:
//
// test('default root route', (t) => {
// t.plan(2)
// const app = build(t)
//
// app.inject({
// url: '/'
// }, (err, res) => {
// t.error(err)
// t.deepEqual(JSON.parse(res.payload), { root: true })
// })
// })