-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboards.js
144 lines (130 loc) · 3.81 KB
/
boards.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
var path = require('path');
var chakram = require(path.join(__dirname, '..', 'chakram')), expect = chakram.expect;
var utils = require(path.join(__dirname, '..', 'utils'));
var methods = require(path.join(__dirname, '..', 'methods'));
var boards = methods.boards;
// describe("[public] Boards", function() {
// it("should return all boards", function () {
// return boards.allCategories()
// .then(function(response) {
// var body = response.body;
// // check the boards
// expect(response).to.have.status(200);
// expect(body).to.have.property('boards');
// expect(body.boards).to.be.an.array;
// expect(body.boards).to.have.length(4);
// // check the threads
// expect(body).to.have.property('threads');
// expect(body.threads).to.be.an.array;
// expect(body.threads).to.have.length(0);
// });
// });
// });
describe("Boards Creation", function() {
var boardInfo = {
name: 'Are you Board?',
slug: 'are-you-board',
description: 'A board for bored people'
};
it("should create a board", function () {
return utils.sudo().then(function(response) {
var options = {
adminToken: response.body.token,
boards: [
{
name: boardInfo.name,
slug: boardInfo.slug,
description: boardInfo.description,
viewable_by: boardInfo.viewable_by,
postable_by: boardInfo.postable_by,
}
]
};
return boards.create(options);
})
.then(function(response) {
expect(response).to.have.status(200);
var boards = response.body;
expect(boards).to.have.length(1);
var board = boards[0];
expect(board).to.have.all.keys([
'id',
'name',
'slug',
'meta',
'description',
'right_to_left'
]);
var id = board.id;
expect(id).to.be.slugid;
boardInfo.id = id;
var name = board.name;
expect(name).to.equal(boardInfo.name);
var slug = board.slug;
expect(slug).to.equal(boardInfo.slug);
var description = board.description;
expect(description).to.equal(boardInfo.description);
});
});
after("delete the created board", function() {
return utils.sudo().then(function(response) {
var options = {
adminToken: response.body.token,
boardIds: [
boardInfo.id
]
};
return boards.delete(options);
});
});
});
describe("Boards Deletion", function() {
var boardInfo = {
name: 'Are you Board?',
slug: 'are-you-board',
description: 'A board for bored people'
};
before("create the board to delete", function() {
return utils.sudo().then(function(response) {
var options = {
adminToken: response.body.token,
boards: [
{
name: boardInfo.name,
slug: boardInfo.slug,
description: boardInfo.description,
viewable_by: boardInfo.viewable_by,
postable_by: boardInfo.postable_by,
}
]
};
return boards.create(options);
})
.then(function(response) {
boardInfo.id = response.body[0].id;
});
});
it("should delete a board", function () {
return utils.sudo().then(function(response) {
var options = {
adminToken: response.body.token,
boardIds: [
boardInfo.id
]
};
return boards.delete(options);
})
.then(function(response) {
expect(response).to.have.status(200);
var boards = response.body;
expect(boards).to.have.length(1);
var board = boards[0];
expect(board).to.have.all.keys(['id', 'name']);
var id = board.id;
expect(id).to.be.a.string;
boardInfo.id = id;
var name = board.name;
expect(name).to.equal(boardInfo.name);
});
});
});