-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.test.js
More file actions
85 lines (71 loc) · 1.45 KB
/
index.test.js
File metadata and controls
85 lines (71 loc) · 1.45 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// TODO: use testing libraries to perform formal tests
const express = require('express'), app = express();
const fs = require('fs');
const expressReply = require('./index');
app.use(expressReply);
app.get('/ok1', (req, res, next) =>{
res._reply({
code: 201,
body: { someKey: "Some Data" },
props: { accessToken: 'loo......ong Token' }
},
{
log: 'all'
})
});
app.get('/ok2', (req, res, next) =>{
res._reply({
code: 200,
body: "Some Data",
props: { accessToken: 'loo......ong Token' }
},
{
log: 'all'
})
});
app.get('/ok3', (req, res, next) =>{
res._reply({
code: 200,
body: Buffer.from("Some Data"),
props: { accessToken: 'loo......ong Token' }
},
{
log: 'all'
})
});
app.get('/ok4', (req, res, next) =>{
res._reply({
code: 200,
body: NaN, // null, undefined
props: { accessToken: 'loo......ong Token' }
},
{
log: 'all'
})
});
app.get('/ok5', (req, res, next) =>{
res._reply({
code: 200,
headers: {
'content-disposition': "attachment; filename=example-image.jpeg"
},
body: fs.createReadStream('./resources/example.jpeg'), // null, undefined
},
{
log: 'all'
})
});
app.get('/ko1', (req, res, next) =>{
res._reply({
code: 200,
body: new Error("Some Data"),
props: { accessToken: 'loo......ong Token' }
},
{
log: 'all'
})
});
app.get('/ko2', (req, res, next) =>{
res._reply(new Error("Some Data"), { log: 'all' })
});
app.listen(process.env.PORT || 3000, () => console.log("Started"));