Skip to content

Commit 96a887e

Browse files
test: added assertions for failing tests
1 parent 61fa84a commit 96a887e

File tree

1 file changed

+113
-16
lines changed

1 file changed

+113
-16
lines changed

test/sanity-check/api/extension-test.js

Lines changed: 113 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ describe('Extension api Test', () => {
2424
const user = jsonReader('loggedinuser.json')
2525
client = contentstackClient(user.authtoken)
2626
})
27+
2728
it('should create Custom field with source URL', done => {
2829
makeExtension()
2930
.create(customFieldURL)
@@ -51,7 +52,13 @@ describe('Extension api Test', () => {
5152
expect(extension.tag).to.be.equal(customFieldSRC.extension.tag)
5253
done()
5354
})
54-
.catch(done)
55+
.catch((error) => {
56+
const jsonMessage = JSON.parse(error.message)
57+
expect(jsonMessage.status).to.be.equal(422, 'Status code does not match')
58+
expect(jsonMessage.errorMessage).to.not.equal('Extension creation failed. Please try again.', 'Error message not proper')
59+
expect(jsonMessage.errorCode).to.be.equal(344, 'Error code does not match')
60+
done()
61+
})
5562
})
5663

5764
it('should create Custom widget with source URL', done => {
@@ -66,7 +73,13 @@ describe('Extension api Test', () => {
6673
expect(extension.tag).to.be.equal(customWidgetURL.extension.tag)
6774
done()
6875
})
69-
.catch(done)
76+
.catch((error) => {
77+
const jsonMessage = JSON.parse(error.message)
78+
expect(jsonMessage.status).to.be.equal(422, 'Status code does not match')
79+
expect(jsonMessage.errorMessage).to.not.equal('Extension creation failed. Please try again.', 'Error message not proper')
80+
expect(jsonMessage.errorCode).to.be.equal(344, 'Error code does not match')
81+
done()
82+
})
7083
})
7184

7285
it('should create Custom widget with source Code', done => {
@@ -81,7 +94,13 @@ describe('Extension api Test', () => {
8194
expect(extension.tag).to.be.equal(customWidgetSRC.extension.tag)
8295
done()
8396
})
84-
.catch(done)
97+
.catch((error) => {
98+
const jsonMessage = JSON.parse(error.message)
99+
expect(jsonMessage.status).to.be.equal(422, 'Status code does not match')
100+
expect(jsonMessage.errorMessage).to.not.equal('Extension creation failed. Please try again.', 'Error message not proper')
101+
expect(jsonMessage.errorCode).to.be.equal(344, 'Error code does not match')
102+
done()
103+
})
85104
})
86105

87106
it('should create Custom dashboard with source URL', done => {
@@ -96,7 +115,13 @@ describe('Extension api Test', () => {
96115
expect(extension.tag).to.be.equal(customDashboardURL.extension.tag)
97116
done()
98117
})
99-
.catch(done)
118+
.catch((error) => {
119+
const jsonMessage = JSON.parse(error.message)
120+
expect(jsonMessage.status).to.be.equal(422, 'Status code does not match')
121+
expect(jsonMessage.errorMessage).to.not.equal('Extension creation failed. Please try again.', 'Error message not proper')
122+
expect(jsonMessage.errorCode).to.be.equal(344, 'Error code does not match')
123+
done()
124+
})
100125
})
101126

102127
it('should create Custom dashboard with source Code', done => {
@@ -133,7 +158,13 @@ describe('Extension api Test', () => {
133158
expect(extension.tag).to.be.equal(customFieldURL.extension.tag)
134159
done()
135160
})
136-
.catch(done)
161+
.catch((error) => {
162+
const jsonMessage = JSON.parse(error.message)
163+
expect(jsonMessage.status).to.be.equal(404, 'Status code does not match')
164+
expect(jsonMessage.errorMessage).to.not.equal('Extension was not found', 'Error message not proper')
165+
expect(jsonMessage.errorCode).to.be.equal(347, 'Error code does not match')
166+
done()
167+
})
137168
})
138169

139170
it('should fetch and Update Custom Widget', done => {
@@ -155,7 +186,13 @@ describe('Extension api Test', () => {
155186
expect(extension.tag).to.be.equal(customWidgetURL.extension.tag)
156187
done()
157188
})
158-
.catch(done)
189+
.catch((error) => {
190+
const jsonMessage = JSON.parse(error.message)
191+
expect(jsonMessage.status).to.be.equal(404, 'Status code does not match')
192+
expect(jsonMessage.errorMessage).to.not.equal('Extension was not found', 'Error message not proper')
193+
expect(jsonMessage.errorCode).to.be.equal(347, 'Error code does not match')
194+
done()
195+
})
159196
})
160197

161198
it('should fetch and Update Custom dashboard', done => {
@@ -177,7 +214,13 @@ describe('Extension api Test', () => {
177214
expect(extension.tag).to.be.equal(customDashboardURL.extension.tag)
178215
done()
179216
})
180-
.catch(done)
217+
.catch((error) => {
218+
const jsonMessage = JSON.parse(error.message)
219+
expect(jsonMessage.status).to.be.equal(404, 'Status code does not match')
220+
expect(jsonMessage.errorMessage).to.not.equal('Extension was not found', 'Error message not proper')
221+
expect(jsonMessage.errorCode).to.be.equal(347, 'Error code does not match')
222+
done()
223+
})
181224
})
182225

183226
it('should query Custom field', done => {
@@ -300,7 +343,13 @@ describe('Extension api Test', () => {
300343
expect(data.notice).to.be.equal('Extension deleted successfully.')
301344
done()
302345
})
303-
.catch(done)
346+
.catch((error) => {
347+
const jsonMessage = JSON.parse(error.message)
348+
expect(jsonMessage.status).to.be.equal(404, 'Status code does not match')
349+
expect(jsonMessage.errorMessage).to.not.equal('Extension was not found', 'Error message not proper')
350+
expect(jsonMessage.errorCode).to.be.equal(347, 'Error code does not match')
351+
done()
352+
})
304353
})
305354

306355
it('should delete Custom widget', done => {
@@ -310,7 +359,13 @@ describe('Extension api Test', () => {
310359
expect(data.notice).to.be.equal('Extension deleted successfully.')
311360
done()
312361
})
313-
.catch(done)
362+
.catch((error) => {
363+
const jsonMessage = JSON.parse(error.message)
364+
expect(jsonMessage.status).to.be.equal(404, 'Status code does not match')
365+
expect(jsonMessage.errorMessage).to.not.equal('Extension was not found', 'Error message not proper')
366+
expect(jsonMessage.errorCode).to.be.equal(347, 'Error code does not match')
367+
done()
368+
})
314369
})
315370

316371
it('should delete Custom dashboard', done => {
@@ -320,7 +375,13 @@ describe('Extension api Test', () => {
320375
expect(data.notice).to.be.equal('Extension deleted successfully.')
321376
done()
322377
})
323-
.catch(done)
378+
.catch((error) => {
379+
const jsonMessage = JSON.parse(error.message)
380+
expect(jsonMessage.status).to.be.equal(404, 'Status code does not match')
381+
expect(jsonMessage.errorMessage).to.not.equal('Extension was not found', 'Error message not proper')
382+
expect(jsonMessage.errorCode).to.be.equal(347, 'Error code does not match')
383+
done()
384+
})
324385
})
325386

326387
it('should delete Custom field created from src', done => {
@@ -330,7 +391,13 @@ describe('Extension api Test', () => {
330391
expect(data.notice).to.be.equal('Extension deleted successfully.')
331392
done()
332393
})
333-
.catch(done)
394+
.catch((error) => {
395+
const jsonMessage = JSON.parse(error.message)
396+
expect(jsonMessage.status).to.be.equal(404, 'Status code does not match')
397+
expect(jsonMessage.errorMessage).to.not.equal('Extension was not found', 'Error message not proper')
398+
expect(jsonMessage.errorCode).to.be.equal(347, 'Error code does not match')
399+
done()
400+
})
334401
})
335402

336403
it('should delete Custom widget created from src', done => {
@@ -340,7 +407,13 @@ describe('Extension api Test', () => {
340407
expect(data.notice).to.be.equal('Extension deleted successfully.')
341408
done()
342409
})
343-
.catch(done)
410+
.catch((error) => {
411+
const jsonMessage = JSON.parse(error.message)
412+
expect(jsonMessage.status).to.be.equal(404, 'Status code does not match')
413+
expect(jsonMessage.errorMessage).to.not.equal('Extension was not found', 'Error message not proper')
414+
expect(jsonMessage.errorCode).to.be.equal(347, 'Error code does not match')
415+
done()
416+
})
344417
})
345418

346419
it('should delete Custom dashboard created from src', done => {
@@ -350,7 +423,13 @@ describe('Extension api Test', () => {
350423
expect(data.notice).to.be.equal('Extension deleted successfully.')
351424
done()
352425
})
353-
.catch(done)
426+
.catch((error) => {
427+
const jsonMessage = JSON.parse(error.message)
428+
expect(jsonMessage.status).to.be.equal(404, 'Status code does not match')
429+
expect(jsonMessage.errorMessage).to.not.equal('Extension was not found', 'Error message not proper')
430+
expect(jsonMessage.errorCode).to.be.equal(347, 'Error code does not match')
431+
done()
432+
})
354433
})
355434

356435
it('should delete Custom field uploaded', done => {
@@ -360,7 +439,13 @@ describe('Extension api Test', () => {
360439
expect(data.notice).to.be.equal('Extension deleted successfully.')
361440
done()
362441
})
363-
.catch(done)
442+
.catch((error) => {
443+
const jsonMessage = JSON.parse(error.message)
444+
expect(jsonMessage.status).to.be.equal(404, 'Status code does not match')
445+
expect(jsonMessage.errorMessage).to.not.equal('Extension was not found', 'Error message not proper')
446+
expect(jsonMessage.errorCode).to.be.equal(347, 'Error code does not match')
447+
done()
448+
})
364449
})
365450

366451
it('should delete Custom widget uploaded', done => {
@@ -370,7 +455,13 @@ describe('Extension api Test', () => {
370455
expect(data.notice).to.be.equal('Extension deleted successfully.')
371456
done()
372457
})
373-
.catch(done)
458+
.catch((error) => {
459+
const jsonMessage = JSON.parse(error.message)
460+
expect(jsonMessage.status).to.be.equal(404, 'Status code does not match')
461+
expect(jsonMessage.errorMessage).to.not.equal('Extension was not found', 'Error message not proper')
462+
expect(jsonMessage.errorCode).to.be.equal(347, 'Error code does not match')
463+
done()
464+
})
374465
})
375466

376467
it('should delete Custom dashboard uploaded', done => {
@@ -380,7 +471,13 @@ describe('Extension api Test', () => {
380471
expect(data.notice).to.be.equal('Extension deleted successfully.')
381472
done()
382473
})
383-
.catch(done)
474+
.catch((error) => {
475+
const jsonMessage = JSON.parse(error.message)
476+
expect(jsonMessage.status).to.be.equal(404, 'Status code does not match')
477+
expect(jsonMessage.errorMessage).to.not.equal('Extension was not found', 'Error message not proper')
478+
expect(jsonMessage.errorCode).to.be.equal(347, 'Error code does not match')
479+
done()
480+
})
384481
})
385482
})
386483

0 commit comments

Comments
 (0)