diff options
author | John McLear <john@mclear.co.uk> | 2014-12-29 15:08:30 +0100 |
---|---|---|
committer | John McLear <john@mclear.co.uk> | 2014-12-29 15:08:30 +0100 |
commit | c9b0c6896e2e6a4f20151df00edd3aa07d240e94 (patch) | |
tree | 97f48685fa5de42869bc9483822b8996d10c7d40 /tests | |
parent | 302ceb665b2dd123d8c67efe05773646ab7aebbf (diff) | |
download | etherpad-lite-c9b0c6896e2e6a4f20151df00edd3aa07d240e94.zip |
move pad tests - still need to do copy pad and some other functionality IE force
Diffstat (limited to 'tests')
-rw-r--r-- | tests/backend/specs/api/pad.js | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/tests/backend/specs/api/pad.js b/tests/backend/specs/api/pad.js index 700c498f..a20c9233 100644 --- a/tests/backend/specs/api/pad.js +++ b/tests/backend/specs/api/pad.js @@ -61,6 +61,16 @@ describe('Permission', function(){ -> setText(padId) -> getLastEdited(padID) -- Should be when setText was performed -> padUsers(padID) -- Should be when setText was performed + + -> setText(padId, "hello world") + -> getLastEdited(padID) -- Should be when pad was made + -> getText(padId) -- Should be "hello world" + -> movePad(padID, newPadId) -- Should provide consistant pad data + -> getText(newPadId) -- Should be "hello world" + -> movePad(newPadID, originalPadId) -- Should provide consistant pad data + -> getText(originalPadId) -- Should be "hello world" + -> getLastEdited(padID) -- Should not be 0 + */ describe('deletePad', function(){ @@ -265,7 +275,125 @@ describe('padUsers', function(){ }); }) +describe('deletePad', function(){ + it('deletes a Pad', function(done) { + api.get(endPoint('deletePad')+"&padID="+testPadId) + .expect(function(res){ + if(res.body.code !== 0) throw new Error("Pad Deletion failed") + }) + .expect('Content-Type', /json/) + .expect(200, done) + }); +}) + +var originalPadId = testPadId; +var newPadId = makeid(); + +describe('createPad', function(){ + it('creates a new Pad with text', function(done) { + api.get(endPoint('createPad')+"&padID="+testPadId) + .expect(function(res){ + if(res.body.code !== 0) throw new Error("Pad Creation failed") + }) + .expect('Content-Type', /json/) + .expect(200, done) + }); +}) + +describe('setText', function(){ + it('Sets text on a pad Id', function(done) { + api.get(endPoint('setText')+"&padID="+testPadId+"&text=hello world") + .expect(function(res){ + if(res.body.code !== 0) throw new Error("Pad Set Text failed") + }) + .expect('Content-Type', /json/) + .expect(200, done) + }); +}) + +describe('getText', function(){ + it('Gets text on a pad Id', function(done) { + api.get(endPoint('getText')+"&padID="+testPadId) + .expect(function(res){ + if(res.body.code !== 0) throw new Error("Pad Get Text failed") + if(res.body.data.text !== "hello world\n") throw new Error("Pad Text not set properly"); + }) + .expect('Content-Type', /json/) + .expect(200, done) + }); +}) + +describe('getLastEdited', function(){ + it('Gets when pad was last edited', function(done) { + api.get(endPoint('getLastEdited')+"&padID="+testPadId) + .expect(function(res){ + if(res.body.lastEdited === 0) throw new Error("Get Last Edited Failed") + }) + .expect('Content-Type', /json/) + .expect(200, done) + }); +}) + +describe('movePad', function(){ + it('Move a Pad to a different Pad ID', function(done) { + api.get(endPoint('movePad')+"&sourceID="+testPadId+"&destinationID="+newPadId+"&force=true") + .expect(function(res){ + console.log(res.body); + if(res.body.code !== 0) throw new Error("Moving Pad Failed") + }) + .expect('Content-Type', /json/) + .expect(200, done) + }); +}) + +describe('getText', function(){ + it('Gets text on a pad Id', function(done) { + api.get(endPoint('getText')+"&padID="+newPadId) + .expect(function(res){ + if(res.body.data.text !== "hello world\n") throw new Error("Pad Get Text failed") + }) + .expect('Content-Type', /json/) + .expect(200, done) + }); +}) + +describe('movePad', function(){ + it('Move a Pad to a different Pad ID', function(done) { + api.get(endPoint('movePad')+"&sourceID="+newPadId+"&destinationID="+testPadId+"&force=false") + .expect(function(res){ + if(res.body.code !== 0) throw new Error("Moving Pad Failed") + }) + .expect('Content-Type', /json/) + .expect(200, done) + }); +}) + +describe('getText', function(){ + it('Gets text on a pad Id', function(done) { + api.get(endPoint('getText')+"&padID="+testPadId) + .expect(function(res){ + if(res.body.data.text !== "hello world\n") throw new Error("Pad Get Text failed") + }) + .expect('Content-Type', /json/) + .expect(200, done) + }); +}) +describe('getLastEdited', function(){ + it('Gets when pad was last edited', function(done) { + api.get(endPoint('getLastEdited')+"&padID="+testPadId) + .expect(function(res){ + if(res.body.lastEdited === 0) throw new Error("Get Last Edited Failed") + }) + .expect('Content-Type', /json/) + .expect(200, done) + }); +}) + +/* + -> movePadForce Test + +*/ var endPoint = function(point){ return '/api/'+apiVersion+'/'+point+'?apikey='+apiKey; |