-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.js
95 lines (84 loc) · 2.92 KB
/
tests.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
94
95
var APIeasy = require('api-easy'),
sys = require('sys'),
assert = require('assert'),
route = {'host': "localhost", 'port': 4000};
var suite = APIeasy.describe('your/awesome/api');
//usage : https://github.com/indexzero/api-easy/#using-api-easy
// exmaple : https://github.com/indexzero/api-easy/blob/master/test/run-test.js
suite.discuss('When using Guacamole REST API')
.use(route.host, route.port)
.setHeader('Content-Type', 'application/json')
//.post({ test: 'data' })
// --- GET documents/+ ---
.get('/')
.expect('should contains a dropzone', function (err, res, body) {
assert.ok(body.toString().contains('dropzone'))
console.log(body.toString());
})
.get('/documents')
.expect(200)
.get('/documents/donotremovejpg')
.expect(200)
.expect('should contains valid response', function (err, res, body) {
body = JSON.parse(body);
assert.equal(body.slug, 'donotremovejpg');
assert.equal(body.resource.name, 'donotremove.jpg');
})
// --- GET tags/+ ---
.get('/tags')
.expect(200)
// --- GET documentation ---
.next()
.get('/documentation')
.expect(200)
//.expect(200, { ok: true })
//.expect('should respond with x-test-header', function (err, res, body) {
// assert.include(res.headers, 'x-test-header');
//})
.export(module);
/*
vows.describe('Guacamole routes test suite').addBatch({
'GET /': {
topic: api.get('/'),
'should respond with a 200 OK': assertStatus(200)
},
'GET /documents': {
topic: api.get('/documents'),
'should respond with a 200 OK': assertStatus(200)
},
'GET /documents/donotremovejpg': {
topic: api.get('/documents/donotremovejpg'),
'should respond with a 200 OK': assertStatus(200),
},
'GET /documents/donotremovejpg': {
topic: api.getBody('/documents/donotremovejpg'),
'should respond with a 200 OK': assertContains('jpg')
},
'GET /tags': {
topic: api.get('/tags'),
'should respond with a 200 OK': assertStatus(200)
},
'GET /tags/semantic': {
topic: api.get('/tags/semantic'),
'should respond with a 200 OK': assertStatus(200)
},
'GET /tags/starting/a': {
topic: api.get('/tags/semantic'),
'should respond with a 200 OK': assertStatus(200)
},
'GET /tags/starting/zzz': {
topic: api.get('/tags/semantic'),
//'should respond with a 204 OK': assertStatus(204)
// Unfortunatly 204 does not work. a firebug try using $.get() return 204 anyway...
'should respond with a 200 (well, a 204 in fact)': assertStatus(200)
},
'GET /tags/treeview': {
topic: api.get('/tags/treeview'),
'should respond with a 200 OK': assertStatus(200)
},
'GET /documentation': {
topic: api.get('/documentation'),
'should respond with a 200 OK': assertStatus(200)
}
}).run();
*/