Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/update deps #55

Merged
merged 2 commits into from Sep 20, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -15,10 +15,10 @@
"author": "",
"license": "ISC",
"dependencies": {
"@hapi/boom": "7.4.3",
"@hapi/boom": "7.4.7",
"@hapi/hapi": "18.4.0",
"@hapi/inert": "5.2.2",
"@hapi/joi": "16.1.1",
"@hapi/joi": "16.1.2",
"@hapi/vision": "5.5.4",
"blipp": "4.0.1",
"govuk-frontend": "3.2.0",
Expand All @@ -32,6 +32,6 @@
"@hapi/lab": "20.2.2",
"codeclimate-test-reporter": "0.5.1",
"node-sass": "4.12.0",
"standard": "14.3.0"
"standard": "14.3.1"
}
}
6 changes: 2 additions & 4 deletions server/routes/about.js
@@ -1,9 +1,7 @@
module.exports = {
method: 'GET',
path: '/about',
options: {
handler: {
view: 'about'
}
handler: {
view: 'about'
}
}
28 changes: 22 additions & 6 deletions server/routes/home.js
@@ -1,12 +1,28 @@
module.exports = {
const joi = require('@hapi/joi')

module.exports = [{
method: 'GET',
path: '/',
handler: (request, h) => {
return h.view('home', {
title: 'Hello',
message: 'World'
})
}
}, {
method: 'POST',
path: '/',
handler: (request, h) => {
return h.view('home', {
title: 'Hello',
message: 'World'
})
},
options: {
handler: (request, h) => {
return h.view('home', {
title: 'Hello',
message: 'World'
validate: {
payload: joi.object().keys({
email: joi.string().email().required()
})
}
}
}
}]
28 changes: 11 additions & 17 deletions server/routes/public.js
@@ -1,31 +1,25 @@
module.exports = [{
method: 'GET',
path: '/robots.txt',
options: {
handler: {
file: 'server/public/static/robots.txt'
}
handler: {
file: 'server/public/static/robots.txt'
}
}, {
method: 'GET',
path: '/assets/all.js',
options: {
handler: {
file: 'node_modules/govuk-frontend/govuk/all.js'
}
handler: {
file: 'node_modules/govuk-frontend/govuk/all.js'
}
}, {
method: 'GET',
path: '/assets/{path*}',
options: {
handler: {
directory: {
path: [
'server/public/static',
'server/public/build',
'node_modules/govuk-frontend/govuk/assets'
]
}
handler: {
directory: {
path: [
'server/public/static',
'server/public/build',
'node_modules/govuk-frontend/govuk/assets'
]
}
}
}]
27 changes: 27 additions & 0 deletions test/index.js
Expand Up @@ -22,6 +22,33 @@ lab.experiment('Web test', () => {
Code.expect(response.headers['content-type']).to.include('text/html')
})

lab.test('POST / route works', async () => {
const options = {
method: 'POST',
url: '/',
payload: {
email: 'a@b.com'
}
}

const response = await server.inject(options)
Code.expect(response.statusCode).to.equal(200)
Code.expect(response.headers['content-type']).to.include('text/html')
})

lab.test('POST / route fails with invalid payload', async () => {
const options = {
method: 'POST',
url: '/',
payload: {
email: 'a@b'
}
}

const response = await server.inject(options)
Code.expect(response.statusCode).to.equal(400)
})

lab.test('GET /about route works', async () => {
const options = {
method: 'GET',
Expand Down