Files
hiring-test-one/example/mock/mocks/trees.mock.js

39 lines
822 B
JavaScript
Raw Normal View History

2015-11-19 16:03:01 +00:00
const data = [
{ id: 1, name: 'Conifer', maxHeight: 115 },
{ id: 2, name: 'Eucalyptus', maxHeight: 210 },
{ id: 3, name: 'Ash', maxHeight: 40 },
{ id: 4, name: 'Elder', maxHeight: 5 },
{ id: 5, name: 'Holly', maxHeight: 10 }
]
2015-11-18 16:37:16 +00:00
module.exports = [
2015-11-19 16:03:01 +00:00
/* CREATE */
2015-11-18 16:37:16 +00:00
{
2015-11-19 16:03:01 +00:00
request: { method: 'POST' },
2015-11-18 16:37:16 +00:00
response: {
2015-11-19 16:03:01 +00:00
status: 201,
location: '/tree/1'
2015-11-18 16:37:16 +00:00
}
},
2015-11-19 16:03:01 +00:00
/* READ */
2015-11-18 16:37:16 +00:00
{
2015-11-19 16:03:01 +00:00
request: { method: 'GET' },
2015-11-18 16:37:16 +00:00
response: {
2015-11-19 16:03:01 +00:00
status: 200,
body: function (ctx) {
return data.filter(tree => tree.maxHeight > Number(ctx.query.tallerThan))
}
2015-11-18 16:37:16 +00:00
}
2015-11-19 16:03:01 +00:00
},
/* UPDATE (forbidden on collection)*/
{
request: { method: 'PUT' },
response: { status: 404 }
},
/* DELETE (forbidden on collection) */
{
request: { method: 'DELETE' },
response: { status: 404 }
2015-11-18 16:37:16 +00:00
}
]