@tiledesk/tiledesk-server 2.10.15 → 2.10.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/app.js +2 -1
  3. package/models/request.js +8 -0
  4. package/package.json +4 -3
  5. package/pubmodules/activities/test/activityRoute.js +6 -2
  6. package/pubmodules/events/test/eventRoute.js +7 -3
  7. package/pubmodules/pubModulesManager.js +24 -0
  8. package/pubmodules/voice-twilio/index.js +6 -0
  9. package/pubmodules/voice-twilio/listener.js +59 -0
  10. package/routes/campaigns.js +1 -1
  11. package/routes/files.js +6 -4
  12. package/routes/images.js +0 -2
  13. package/routes/kb.js +7 -1
  14. package/routes/users.js +2 -2
  15. package/services/fileGridFsService.js +12 -10
  16. package/services/requestService.js +2 -1
  17. package/test/app-test.js +36 -1
  18. package/test/authentication.js +662 -796
  19. package/test/authenticationJwt.js +213 -315
  20. package/test/authorization.js +53 -72
  21. package/test/campaignsRoute.js +42 -47
  22. package/test/cannedRoute.js +30 -16
  23. package/test/departmentService.js +222 -274
  24. package/test/example.json +31 -1
  25. package/test/faqRoute.js +713 -622
  26. package/test/faqService.js +124 -159
  27. package/test/faqkbRoute.js +128 -100
  28. package/test/fileRoute.js +50 -46
  29. package/test/imageRoute.js +263 -254
  30. package/test/jwtRoute.js +128 -153
  31. package/test/kbRoute.js +40 -17
  32. package/test/kbsettingsRoute.js +78 -54
  33. package/test/keysRoute.js +6 -7
  34. package/test/labelRoute.js +591 -696
  35. package/test/labelService.js +40 -47
  36. package/test/leadService.js +100 -115
  37. package/test/logsRoute.js +13 -7
  38. package/test/messageRootRoute.js +112 -102
  39. package/test/messageRoute.js +1171 -1419
  40. package/test/messageService.js +41 -43
  41. package/test/openaiRoute.js +5 -1
  42. package/test/projectRoute.js +23 -4
  43. package/test/projectService.js +3 -1
  44. package/test/quoteManager.js +36 -13
  45. package/test/requestRoute.js +103 -72
  46. package/test/requestService.js +51 -51
  47. package/test/userRoute.js +37 -8
  48. package/test/userService.js +34 -31
  49. package/utils/promiseUtil.js +1 -1
@@ -1,6 +1,6 @@
1
1
  //During the test the env variable is set to test
2
2
  process.env.NODE_ENV = 'test';
3
-
3
+ process.env.LOG_LEVEL = 'critical';
4
4
 
5
5
  //Require the dev-dependencies
6
6
  let chai = require('chai');
@@ -10,6 +10,9 @@ let server = require('../app');
10
10
  let should = chai.should();
11
11
  var fs = require('fs');
12
12
  var userService = require('../services/userService');
13
+ const projectService = require('../services/projectService');
14
+
15
+ let log = false;
13
16
 
14
17
  // chai.config.includeStack = true;
15
18
 
@@ -20,303 +23,309 @@ chai.use(chaiHttp);
20
23
 
21
24
  describe('ImagesRoute', () => {
22
25
 
23
- describe('/upload', () => {
24
-
25
-
26
+ describe('/upload', () => {
26
27
 
27
- it('upload-user', (done) => {
28
+ it('upload-user', (done) => {
28
29
 
29
- var email = "test-signup-" + Date.now() + "@email.com";
30
- var pwd = "pwd";
31
-
32
- userService.signup( email ,pwd, "Test Firstname", "Test lastname").then(function(savedUser) {
33
-
34
- chai.request(server)
35
- .post('/images/users/')
36
- .auth(email, pwd)
37
- .set('Content-Type','image/jpeg')
38
- .attach('file', fs.readFileSync('./test/test-image.png'), 'test-image.png')
39
- // .field('delimiter', ';')
40
- .end((err, res) => {
41
- //console.log("res", res);
42
- console.log("res.body", res.body);
43
- res.should.have.status(201);
44
- res.body.should.be.a('object');
45
- expect(res.body.message).to.equal('Image uploded successfully');
46
- expect(res.body.filename).to.not.equal(null);
47
- expect(res.body.filename).to.containIgnoreSpaces('test-image.png');
48
- expect(res.body.filename).to.containIgnoreSpaces('users','images');
49
- expect(res.body.thumbnail).to.not.equal(null);
50
- done();
51
- });
52
-
30
+ var email = "test-signup-" + Date.now() + "@email.com";
31
+ var pwd = "pwd";
32
+
33
+ userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
34
+
35
+ chai.request(server)
36
+ .post('/images/users/')
37
+ .auth(email, pwd)
38
+ .set('Content-Type', 'image/jpeg')
39
+ .attach('file', fs.readFileSync('./test/test-image.png'), 'test-image.png')
40
+ // .field('delimiter', ';')
41
+ .end((err, res) => {
42
+
43
+ if (err) { console.error("err: ", err); }
44
+ if (log) { console.log("res.body", res.body); }
45
+
46
+ res.should.have.status(201);
47
+ res.body.should.be.a('object');
48
+ expect(res.body.message).to.equal('Image uploded successfully');
49
+ expect(res.body.filename).to.not.equal(null);
50
+ expect(res.body.filename).to.containIgnoreSpaces('test-image.png');
51
+ expect(res.body.filename).to.containIgnoreSpaces('users', 'images');
52
+ expect(res.body.thumbnail).to.not.equal(null);
53
+ done();
54
+ });
55
+
56
+ });
53
57
  });
54
- });
55
58
 
56
59
 
57
- // mocha test/imageRoute.js --grep 'upload-user-folder'
58
- it('upload-user-folder', (done) => {
60
+ // mocha test/imageRoute.js --grep 'upload-user-folder'
61
+ it('upload-user-folder', (done) => {
59
62
 
60
- var email = "test-signup-" + Date.now() + "@email.com";
61
- var pwd = "pwd";
62
-
63
- userService.signup( email ,pwd, "Test Firstname", "Test lastname").then(function(savedUser) {
64
-
65
- chai.request(server)
66
- .put('/images/users')
67
- .auth(email, pwd)
68
- .set('Content-Type','image/jpeg')
69
- .attach('file', fs.readFileSync('./test/test-image.png'), 'profile.png')
70
- // .field('folder', 'myfolder')
71
- .end((err, res) => {
72
- //console.log("res", res);
73
- console.log("res.body", res.body);
74
- res.should.have.status(201);
75
- res.body.should.be.a('object');
76
- expect(res.body.message).to.equal('Image uploded successfully');
77
- expect(res.body.filename).to.not.equal(null);
78
- expect(res.body.filename).to.containIgnoreSpaces('profile.png');
79
- expect(res.body.filename).to.containIgnoreSpaces('users','images');
80
- // assert(res.body.filename.indexOf()).to.have.string('');
81
- // assert.equal(res.body.filename.indexOf('myfilder'), 1);
82
- expect(res.body.thumbnail).to.not.equal(null);
83
-
63
+ var email = "test-signup-" + Date.now() + "@email.com";
64
+ var pwd = "pwd";
84
65
 
66
+ userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
85
67
 
86
- //check duplicate
87
- chai.request(server)
68
+ chai.request(server)
88
69
  .put('/images/users')
89
70
  .auth(email, pwd)
90
- .set('Content-Type','image/jpeg')
91
- .attach('file', fs.readFileSync('./test/test-image.png'), 'profile.png')
71
+ .set('Content-Type', 'image/jpeg')
72
+ .attach('file', fs.readFileSync('./test/test-image.png'), 'profile.png')
92
73
  // .field('folder', 'myfolder')
93
- .end((err, res) => {
94
- res.should.have.status(409);
95
- done();
74
+ .end((err, res) => {
75
+
76
+ if (err) { console.error("err: ", err); }
77
+ if (log) { console.log("res.body", res.body); }
78
+
79
+ res.should.have.status(201);
80
+ res.body.should.be.a('object');
81
+ expect(res.body.message).to.equal('Image uploded successfully');
82
+ expect(res.body.filename).to.not.equal(null);
83
+ expect(res.body.filename).to.containIgnoreSpaces('profile.png');
84
+ expect(res.body.filename).to.containIgnoreSpaces('users', 'images');
85
+ // assert(res.body.filename.indexOf()).to.have.string('');
86
+ // assert.equal(res.body.filename.indexOf('myfilder'), 1);
87
+ expect(res.body.thumbnail).to.not.equal(null);
88
+
89
+ //check duplicate
90
+ chai.request(server)
91
+ .put('/images/users')
92
+ .auth(email, pwd)
93
+ .set('Content-Type', 'image/jpeg')
94
+ .attach('file', fs.readFileSync('./test/test-image.png'), 'profile.png')
95
+ // .field('folder', 'myfolder')
96
+ .end((err, res) => {
97
+ res.should.have.status(409);
98
+ done();
99
+ });
96
100
  });
97
- });
98
-
101
+ });
99
102
  });
100
- });
101
-
102
103
 
103
104
 
105
+ // mocha test/imageRoute.js --grep 'upload-avatar'
106
+ it('upload-avatar', (done) => {
104
107
 
105
- // mocha test/imageRoute.js --grep 'upload-avatar'
106
- it('upload-avatar', (done) => {
108
+ var email = "test-signup-" + Date.now() + "@email.com";
109
+ var pwd = "pwd";
107
110
 
108
- var email = "test-signup-" + Date.now() + "@email.com";
109
- var pwd = "pwd";
111
+ userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
110
112
 
111
- userService.signup( email ,pwd, "Test Firstname", "Test lastname").then(function(savedUser) {
112
-
113
- chai.request(server)
114
- .put('/images/users/photo')
115
- .auth(email, pwd)
116
- .set('Content-Type','image/jpeg')
117
- .attach('file', fs.readFileSync('./test/test-image.png'), 'profile.png')
118
- // .field('folder', 'myfolder')
119
- .end((err, res) => {
120
- //console.log("res", res);
121
- console.log("res.body", res.body);
122
- console.log("res.status", res.status);
123
- res.should.have.status(201);
124
- res.body.should.be.a('object');
125
- expect(res.body.message).to.equal('Image uploded successfully');
126
- // expect(res.body.filename).to.not.equal("photo.jpg");
127
- expect(res.body.filename).to.containIgnoreSpaces('photo.jpg');
128
- expect(res.body.filename).to.containIgnoreSpaces('users','images');
129
- // assert(res.body.filename.indexOf()).to.have.string('');
130
- // assert.equal(res.body.filename.indexOf('myfilder'), 1);
131
- expect(res.body.thumbnail).to.not.equal(null);
132
-
133
-
134
-
135
- //check duplicate
136
113
  chai.request(server)
137
- .put('/images/users/photo')
138
- .auth(email, pwd)
139
- .set('Content-Type','image/jpeg')
140
- .attach('file', fs.readFileSync('./test/test-image.png'), 'profile.png')
141
- // .field('folder', 'myfolder')
142
- .end((err, res) => {
143
- res.should.have.status(409);
144
- done();
145
- });
146
- });
147
-
148
- });
149
- }).timeout(1000);
150
-
151
-
152
-
153
-
154
- // mocha test/imageRoute.js --grep 'upload-avatar-force'
155
- it('upload-avatar-force', (done) => {
156
-
157
- var email = "test-signup-" + Date.now() + "@email.com";
158
- var pwd = "pwd";
159
-
160
- userService.signup( email ,pwd, "Test Firstname", "Test lastname").then(function(savedUser) {
161
-
162
- chai.request(server)
163
- .put('/images/users/photo?force=true')
164
- .auth(email, pwd)
165
- .set('Content-Type','image/jpeg')
166
- .attach('file', fs.readFileSync('./test/test-image.png'), 'profile.png')
167
- // .field('folder', 'myfolder')
168
- .end((err, res) => {
169
- //console.log("res", res);
170
- console.log("res.body", res.body);
171
- console.log("res.status", res.status);
172
- res.should.have.status(201);
173
- res.body.should.be.a('object');
174
- expect(res.body.message).to.equal('Image uploded successfully');
175
- // expect(res.body.filename).to.not.equal("photo.jpg");
176
- expect(res.body.filename).to.containIgnoreSpaces('photo.jpg');
177
- expect(res.body.filename).to.containIgnoreSpaces('users','images');
178
- // assert(res.body.filename.indexOf()).to.have.string('');
179
- // assert.equal(res.body.filename.indexOf('myfilder'), 1);
180
- expect(res.body.thumbnail).to.not.equal(null);
181
-
182
-
183
-
184
- //check duplicate
185
- chai.request(server)
186
- .put('/images/users/photo?force=true')
187
- .auth(email, pwd)
188
- .set('Content-Type','image/jpeg')
189
- .attach('file', fs.readFileSync('./test/test-image.png'), 'profile.png')
190
- // .field('folder', 'myfolder')
191
- .end((err, res) => {
192
- res.should.have.status(201);
193
- done();
194
- });
195
- });
196
-
197
- });
198
- });
114
+ .put('/images/users/photo')
115
+ .auth(email, pwd)
116
+ .set('Content-Type', 'image/jpeg')
117
+ .attach('file', fs.readFileSync('./test/test-image.png'), 'profile.png')
118
+ // .field('folder', 'myfolder')
119
+ .end((err, res) => {
120
+
121
+ if (err) { console.error("err: ", err); }
122
+ if (log) { console.log("res.body", res.body); }
123
+
124
+ res.should.have.status(201);
125
+ res.body.should.be.a('object');
126
+ expect(res.body.message).to.equal('Image uploded successfully');
127
+ // expect(res.body.filename).to.not.equal("photo.jpg");
128
+ expect(res.body.filename).to.containIgnoreSpaces('photo.jpg');
129
+ expect(res.body.filename).to.containIgnoreSpaces('users', 'images');
130
+ // assert(res.body.filename.indexOf()).to.have.string('');
131
+ // assert.equal(res.body.filename.indexOf('myfilder'), 1);
132
+ expect(res.body.thumbnail).to.not.equal(null);
133
+
134
+ //check duplicate
135
+ chai.request(server)
136
+ .put('/images/users/photo')
137
+ .auth(email, pwd)
138
+ .set('Content-Type', 'image/jpeg')
139
+ .attach('file', fs.readFileSync('./test/test-image.png'), 'profile.png')
140
+ // .field('folder', 'myfolder')
141
+ .end((err, res) => {
142
+
143
+ res.should.have.status(409);
144
+ done();
145
+ });
146
+ });
147
+ });
148
+ }).timeout(5000);
199
149
 
200
150
 
151
+ // mocha test/imageRoute.js --grep 'upload-avatar-force'
152
+ it('upload-avatar-force', (done) => {
201
153
 
202
- // mocha test/imageRoute.js --grep 'upload-avatar-another-user'
203
- it('upload-avatar-another-user', (done) => {
154
+ var email = "test-signup-" + Date.now() + "@email.com";
155
+ var pwd = "pwd";
204
156
 
205
- var email = "test-signup-" + Date.now() + "@email.com";
206
- var pwd = "pwd";
157
+ userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
207
158
 
208
- userService.signup( email ,pwd, "Test Firstname", "Test lastname").then(function(savedUser) {
209
- var bot = "bot_"+ Date.now();
210
- chai.request(server)
211
- .put('/images/users/photo?user_id='+bot)
212
- .auth(email, pwd)
213
- .set('Content-Type','image/jpeg')
214
- .attach('file', fs.readFileSync('./test/test-image.png'), 'profile.png')
215
- // .field('folder', 'myfolder')
216
- .end((err, res) => {
217
- //console.log("res", res);
218
- console.log("res.body", res.body);
219
- console.log("res.status", res.status);
220
- res.should.have.status(201);
221
- res.body.should.be.a('object');
222
- expect(res.body.message).to.equal('Image uploded successfully');
223
- expect(res.body.filename).to.not.equal("photo.jpg");
224
- // assert(res.body.filename.indexOf()).to.have.string('');
225
- // assert.equal(res.body.filename.indexOf('myfilder'), 1);
226
- expect(res.body.thumbnail).to.not.equal(null);
227
- // expect(res.body.filename).to.include.keys(bot);
228
- expect(res.body.filename).to.containIgnoreSpaces(bot);
159
+ chai.request(server)
160
+ .put('/images/users/photo?force=true')
161
+ .auth(email, pwd)
162
+ .set('Content-Type', 'image/jpeg')
163
+ .attach('file', fs.readFileSync('./test/test-image.png'), 'profile.png')
164
+ // .field('folder', 'myfolder')
165
+ .end((err, res) => {
166
+
167
+ if (err) { console.error("err: ", err); }
168
+ if (log) { console.log("res.body", res.body); }
169
+
170
+ res.should.have.status(201);
171
+ res.body.should.be.a('object');
172
+ expect(res.body.message).to.equal('Image uploded successfully');
173
+ // expect(res.body.filename).to.not.equal("photo.jpg");
174
+ expect(res.body.filename).to.containIgnoreSpaces('photo.jpg');
175
+ expect(res.body.filename).to.containIgnoreSpaces('users', 'images');
176
+ // assert(res.body.filename.indexOf()).to.have.string('');
177
+ // assert.equal(res.body.filename.indexOf('myfilder'), 1);
178
+ expect(res.body.thumbnail).to.not.equal(null);
179
+
180
+ //check duplicate
181
+ chai.request(server)
182
+ .put('/images/users/photo?force=true')
183
+ .auth(email, pwd)
184
+ .set('Content-Type', 'image/jpeg')
185
+ .attach('file', fs.readFileSync('./test/test-image.png'), 'profile.png')
186
+ // .field('folder', 'myfolder')
187
+ .end((err, res) => {
188
+ res.should.have.status(201);
189
+ done();
190
+ });
191
+ });
192
+ });
193
+ });
229
194
 
230
195
 
196
+ // mocha test/imageRoute.js --grep 'upload-avatar-another-user'
197
+ it('upload-avatar-another-user', (done) => {
231
198
 
232
- //check duplicate
233
- chai.request(server)
234
- .put('/images/users/photo?user_id='+bot)
235
- .auth(email, pwd)
236
- .set('Content-Type','image/jpeg')
237
- .attach('file', fs.readFileSync('./test/test-image.png'), 'profile.png')
238
- // .field('folder', 'myfolder')
239
- .end((err, res) => {
240
- res.should.have.status(409);
241
- done();
242
- });
243
- });
244
-
245
- });
246
- });
199
+ var email = "test-signup-" + Date.now() + "@email.com";
200
+ var pwd = "pwd";
247
201
 
202
+ userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
203
+ projectService.create("test-faqkb-create", savedUser._id).then(function (savedProject) {
248
204
 
205
+ chai.request(server)
206
+ .post('/' + savedProject._id + '/faq_kb')
207
+ .auth(email, pwd)
208
+ .send({ "name": "testbot", type: "internal", template: "example", language: 'en' })
209
+ .end((err, res) => {
210
+ if (err) { console.error("err: ", err); }
211
+ if (log) { console.log("res.body: ", res.body); }
212
+
213
+ //var bot = "bot_" + Date.now();
214
+ let bot_id = res.body._id;
215
+
216
+ chai.request(server)
217
+ .put('/images/users/photo?bot_id=' + bot_id)
218
+ .auth(email, pwd)
219
+ .set('Content-Type', 'image/jpeg')
220
+ .attach('file', fs.readFileSync('./test/test-image.png'), 'profile.png')
221
+ // .field('folder', 'myfolder')
222
+ .end((err, res) => {
223
+
224
+ if (err) { console.error("err: ", err); }
225
+ if (log) { console.log("res.body", res.body); }
226
+
227
+ res.should.have.status(201);
228
+ res.body.should.be.a('object');
229
+ expect(res.body.message).to.equal('Image uploded successfully');
230
+ expect(res.body.filename).to.not.equal("photo.jpg");
231
+ // assert(res.body.filename.indexOf()).to.have.string('');
232
+ // assert.equal(res.body.filename.indexOf('myfilder'), 1);
233
+ expect(res.body.thumbnail).to.not.equal(null);
234
+ // expect(res.body.filename).to.include.keys(bot);
235
+ expect(res.body.filename).to.containIgnoreSpaces(bot_id);
236
+
237
+ //check duplicate
238
+ chai.request(server)
239
+ .put('/images/users/photo?bot_id=' + bot_id)
240
+ .auth(email, pwd)
241
+ .set('Content-Type', 'image/jpeg')
242
+ .attach('file', fs.readFileSync('./test/test-image.png'), 'profile.png')
243
+ // .field('folder', 'myfolder')
244
+ .end((err, res) => {
245
+
246
+ if (err) { console.error("err: ", err); }
247
+ if (log) { console.log("res.body: ", res.body); }
248
+
249
+ res.should.have.status(409);
250
+
251
+ done();
252
+ });
253
+ });
254
+
255
+ })
256
+ });
257
+ })
258
+ });
249
259
 
250
260
 
251
- // mocha test/imageRoute.js --grep 'delete-user-folder'
252
- it('delete-user-folder', (done) => {
261
+ // mocha test/imageRoute.js --grep 'delete-user-folder'
262
+ it('delete-user-folder', (done) => {
253
263
 
254
- var email = "test-signup-" + Date.now() + "@email.com";
255
- var pwd = "pwd";
264
+ var email = "test-signup-" + Date.now() + "@email.com";
265
+ var pwd = "pwd";
256
266
 
257
- userService.signup( email ,pwd, "Test Firstname", "Test lastname").then(function(savedUser) {
258
-
259
- chai.request(server)
260
- .put('/images/users')
261
- .auth(email, pwd)
262
- .set('Content-Type','image/jpeg')
263
- .attach('file', fs.readFileSync('./test/test-image.png'), 'profile.png')
264
- // .field('folder', 'myfolder')
265
- .end((err, res) => {
266
- //console.log("res", res);
267
- console.log("res.body", res.body);
268
- res.should.have.status(201);
269
- res.body.should.be.a('object');
270
- expect(res.body.message).to.equal('Image uploded successfully');
271
- expect(res.body.filename).to.not.equal(null);
272
- // assert(res.body.filename.indexOf()).to.have.string('');
273
- // assert.equal(res.body.filename.indexOf('myfilder'), 1);
274
- expect(res.body.thumbnail).to.not.equal(null);
275
-
267
+ userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
276
268
 
277
269
  chai.request(server)
278
- .delete('/images/users?path='+res.body.filename)
279
- .auth(email, pwd)
280
- .end((err, res) => {
281
- console.log("res.body", res.body);
282
- res.should.have.status(200);
283
- expect(res.body.message).to.equal('Image deleted successfully');
284
- done();
285
- });
286
- });
287
-
288
- });
289
- });
290
-
270
+ .put('/images/users')
271
+ .auth(email, pwd)
272
+ .set('Content-Type', 'image/jpeg')
273
+ .attach('file', fs.readFileSync('./test/test-image.png'), 'profile.png')
274
+ // .field('folder', 'myfolder')
275
+ .end((err, res) => {
276
+
277
+ if (err) { console.error("err: ", err); }
278
+ if (log) { console.log("res.body", res.body); }
279
+
280
+ res.should.have.status(201);
281
+ res.body.should.be.a('object');
282
+ expect(res.body.message).to.equal('Image uploded successfully');
283
+ expect(res.body.filename).to.not.equal(null);
284
+ // assert(res.body.filename.indexOf()).to.have.string('');
285
+ // assert.equal(res.body.filename.indexOf('myfilder'), 1);
286
+ expect(res.body.thumbnail).to.not.equal(null);
287
+
288
+ chai.request(server)
289
+ .delete('/images/users?path=' + res.body.filename)
290
+ .auth(email, pwd)
291
+ .end((err, res) => {
292
+
293
+ if (err) { console.error("err: ", err); }
294
+ if (log) { console.log("res.body", res.body); }
295
+
296
+ res.should.have.status(200);
297
+ expect(res.body.message).to.equal('Image deleted successfully');
298
+ done();
299
+ });
300
+ });
301
+ });
302
+ });
291
303
 
292
304
 
293
- // mocha test/imageRoute.js --grep 'upload-public'
294
- it('upload-public', (done) => {
305
+ // mocha test/imageRoute.js --grep 'upload-public'
306
+ it('upload-public', (done) => {
295
307
 
296
-
297
308
  chai.request(server)
298
- .post('/images/public/')
299
- .set('Content-Type','image/jpeg')
300
- .attach('file', fs.readFileSync('./test/test-image.png'), 'test-image.png')
301
- // .field('delimiter', ';')
302
- .end((err, res) => {
303
- //console.log("res", res);
304
- console.log("res.body", res.body);
309
+ .post('/images/public/')
310
+ .set('Content-Type', 'image/jpeg')
311
+ .attach('file', fs.readFileSync('./test/test-image.png'), 'test-image.png')
312
+ // .field('delimiter', ';')
313
+ .end((err, res) => {
314
+
315
+ if (err) { console.error("err: ", err); }
316
+ if (log) { console.log("res.body", res.body); }
317
+
305
318
  res.should.have.status(201);
306
319
  res.body.should.be.a('object');
307
- expect(res.body.message).to.equal('Image uploded successfully');
308
- expect(res.body.filename).to.not.equal(null);
309
- expect(res.body.thumbnail).to.not.equal(null);
320
+ expect(res.body.message).to.equal('Image uploded successfully');
321
+ expect(res.body.filename).to.not.equal(null);
322
+ expect(res.body.thumbnail).to.not.equal(null);
323
+
310
324
  done();
311
- });
312
-
313
-
325
+ });
326
+ });
314
327
  });
315
328
 
316
-
317
-
318
- });
319
-
320
329
  });
321
330
 
322
331