From 8c4625ec50ead7e3854ece255e6425b75afccbad Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 25 Mar 2020 09:47:30 +0100 Subject: [PATCH] tests: add tests for listAllPads() API call --HG-- branch : padlist-use-set --- tests/backend/specs/api/pad.js | 35 ++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/tests/backend/specs/api/pad.js b/tests/backend/specs/api/pad.js index 67650beb9..d8fde5ada 100644 --- a/tests/backend/specs/api/pad.js +++ b/tests/backend/specs/api/pad.js @@ -173,6 +173,19 @@ describe('getHTML', function(){ }); }) +describe('listAllPads', function () { + it('list all pads', function (done) { + api.get(endPoint('listAllPads')) + .expect(function (res) { + if (res.body.data.padIDs.includes(testPadId) !== true) { + throw new Error('Unable to find pad in pad list') + } + }) + .expect('Content-Type', /json/) + .expect(200, done) + }) +}) + describe('deletePad', function(){ it('deletes a Pad', function(done) { api.get(endPoint('deletePad')+"&padID="+testPadId) @@ -184,6 +197,19 @@ describe('deletePad', function(){ }); }) +describe('listAllPads', function () { + it('list all pads', function (done) { + api.get(endPoint('listAllPads')) + .expect(function (res) { + if (res.body.data.padIDs.includes(testPadId) !== false) { + throw new Error('Test pad should not be in pads list') + } + }) + .expect('Content-Type', /json/) + .expect(200, done) + }) +}) + describe('getHTML', function(){ it('get the HTML of a Pad -- Should return a failure', function(done) { api.get(endPoint('getHTML')+"&padID="+testPadId) @@ -402,11 +428,8 @@ describe('createPad', function(){ describe('setText', function(){ it('Sets text on a pad Id', function(done) { - api.post(endPoint('setText')) - .send({ - "padID": testPadId, - "text": text, - }) + api.post(endPoint('setText')+"&padID="+testPadId) + .field({text: text}) .expect(function(res){ if(res.body.code !== 0) throw new Error("Pad Set Text failed") }) @@ -430,7 +453,7 @@ describe('getText', function(){ describe('setText', function(){ it('Sets text on a pad Id including an explicit newline', function(done) { api.post(endPoint('setText')+"&padID="+testPadId) - .send({text: text+'\n'}) + .field({text: text+'\n'}) .expect(function(res){ if(res.body.code !== 0) throw new Error("Pad Set Text failed") })