forked from Ealenn/Echo-Server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathverbs.js
69 lines (67 loc) · 2.1 KB
/
verbs.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
const assert = require('assert');
const request = require('supertest');
process.env.LOGS__LEVEL = "error";
describe('HTTP Verbs', function () {
var server;
beforeEach(function () {
server = require('../src/app');
});
afterEach(function () {
server.close();
});
it('GET', function test(done) {
request(server)
.get('/')
.expect(function (res) {
assert.strictEqual(res.body.http.method, 'GET')
assert.strictEqual(res.body.http.protocol, 'http')
assert.strictEqual(res.body.http.originalUrl, '/')
assert.strictEqual(res.body.http.baseUrl, '')
})
.expect(200, done);
});
it('POST', function test(done) {
request(server)
.post('/')
.expect(function (res) {
assert.strictEqual(res.body.http.method, 'POST')
assert.strictEqual(res.body.http.protocol, 'http')
assert.strictEqual(res.body.http.originalUrl, '/')
assert.strictEqual(res.body.http.baseUrl, '')
})
.expect(200, done);
});
it('PUT', function test(done) {
request(server)
.put('/')
.expect(function (res) {
assert.strictEqual(res.body.http.method, 'PUT')
assert.strictEqual(res.body.http.protocol, 'http')
assert.strictEqual(res.body.http.originalUrl, '/')
assert.strictEqual(res.body.http.baseUrl, '')
})
.expect(200, done);
});
it('PATCH', function test(done) {
request(server)
.patch('/')
.expect(function (res) {
assert.strictEqual(res.body.http.method, 'PATCH')
assert.strictEqual(res.body.http.protocol, 'http')
assert.strictEqual(res.body.http.originalUrl, '/')
assert.strictEqual(res.body.http.baseUrl, '')
})
.expect(200, done);
});
it('DELETE', function test(done) {
request(server)
.delete('/')
.expect(function (res) {
assert.strictEqual(res.body.http.method, 'DELETE')
assert.strictEqual(res.body.http.protocol, 'http')
assert.strictEqual(res.body.http.originalUrl, '/')
assert.strictEqual(res.body.http.baseUrl, '')
})
.expect(200, done);
});
});