Repository navigation
Expand file tree
/
Copy pathtest.js
More file actions
50 lines (42 loc) · 1.35 KB
/
Copy pathtest.js
File metadata and controls
50 lines (42 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const tape = require('tape')
const jsonist = require('jsonist')
const studentFixture = require('./student.json')
const port = (process.env.PORT = process.env.PORT || require('get-port-sync')())
const endpoint = `http://localhost:${port}`
const server = require('./server')
tape('health', async function (t) {
const url = `${endpoint}/health`
jsonist.get(url, (err, body) => {
if (err) t.error(err)
t.ok(body.success, 'should have successful healthcheck')
t.end()
})
})
tape('save student', async function (t) {
const url = `${endpoint}/studentid123/property1/property2/property3/property4`
jsonist.put(url, studentFixture, (err, body) => {
if (err) t.error(err)
t.ok(body.success, 'should have successful student save')
t.end()
})
})
tape('get student', async function (t) {
const url = `${endpoint}/studentid123/property1/property2/property3/property4`
jsonist.get(url, (err, body) => {
if (err) t.error(err)
t.ok(body.success, 'should have successful student retrieve')
t.end()
})
})
tape('delete student', async function (t) {
const url = `${endpoint}/studentid123/property1/property2/property3/property4`
jsonist.delete(url, (err, body) => {
if (err) t.error(err)
t.ok(body.success, 'should have successful student retrieve')
t.end()
})
})
tape('cleanup', function (t) {
server.close()
t.end()
})