This repository has been archived by the owner on Nov 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.test.js
93 lines (75 loc) · 2.72 KB
/
app.test.js
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
86
87
88
89
90
91
92
93
'use strict';
var request = require('supertest');
var app = require('./app');
// get /
// get dm
// get map
// get quit
// get dm/map
// get dm/listmaps
// post dm/map
// post upload
// post send
describe('Testing DM web access and responses', () => {
// Testing for DMs
test('DM - root page returns 200', async () => {
const response = await request(app).get('/').set('Host', 'localhost:3000');
expect(response.statusCode).toBe(200);
});
test('DM - dm page returns 200', async () => {
const response = await request(app).get('/dm').set('Host', 'localhost:3000');
expect(response.statusCode).toBe(200);
});
test('DM - quit page returns 200', async () => {
const response = await request(app).get('/quit').set('Host', 'localhost:3000');
expect(response.statusCode).toBe(200);
});
test('DM - send page with Base64 coded data returns 200 - success true', async () => {
const response = await request(app).post('/send')
.send({
imageData: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=='
})
.set('Host', 'localhost:3000');
expect(response.body.success).toEqual(true);
});
test('DM - send page with no data returns 200 - success false', async () => {
const response = await request(app).post('/send')
.set('Host', 'localhost:3000');
expect(response.body.success).toEqual(false);
});
});
describe('Testing player web responses', () => {
// Testing for players
test('/ returns status 200', async () => {
const response = await request(app).get('/');
expect(response.statusCode).toBe(200);
});
test('/dm returns status 403', async () => {
const response = await request(app).get('/dm');
expect(response.statusCode).toBe(403);
});
test('/map returns type png/image', async () => {
const response = await request(app).get('/map');
expect(response.type).toBe('image/png');
});
test('/quit returns status 403', async () => {
const response = await request(app).get('/quit');
expect(response.statusCode).toBe(403);
});
test('/dm/map returns status 403', async () => {
const response = await request(app).get('/dm/map');
expect(response.statusCode).toBe(403);
});
test('/dm/listmaps returns status 403', async () => {
const response = await request(app).get('/dm/listmaps');
expect(response.statusCode).toBe(403);
});
test('/send returns 403', async () => {
const response = await request(app).post('/send');
expect(response.statusCode).toBe(403);
});
test('/upload returns 403', async () => {
const response = await request(app).post('/upload');
expect(response.statusCode).toBe(403);
});
});