diff options
author | Ted Mielczarek <ted@mielczarek.org> | 2015-10-19 12:58:47 -0400 |
---|---|---|
committer | Ted Mielczarek <ted@mielczarek.org> | 2015-10-19 15:27:09 -0400 |
commit | a675659dc28b95f8ef5664ffe5d82cd7cf2b2577 (patch) | |
tree | e8c6d997c2bf142586a469afe3a209fbf013f73e /tests/backend/specs/api | |
parent | 504cc102a02396232bb9e29b159e3b5188f85a36 (diff) | |
download | etherpad-lite-a675659dc28b95f8ef5664ffe5d82cd7cf2b2577.zip |
Add an appendText API
Diffstat (limited to 'tests/backend/specs/api')
-rw-r--r-- | tests/backend/specs/api/pad.js | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/tests/backend/specs/api/pad.js b/tests/backend/specs/api/pad.js index 14e99091..e04033c0 100644 --- a/tests/backend/specs/api/pad.js +++ b/tests/backend/specs/api/pad.js @@ -79,6 +79,8 @@ describe('Permission', function(){ -> movePad(newPadID, originalPadId) -- Should provide consistant pad data -> getText(originalPadId) -- Should be "hello world" -> getLastEdited(padID) -- Should not be 0 + -> appendText(padID, "hello") + -> getText(padID) -- Should be "hello worldhello" -> setHTML(padID) -- Should fail on invalid HTML -> setHTML(padID) *3 -- Should fail on invalid HTML -> getHTML(padID) -- Should return HTML close to posted HTML @@ -483,6 +485,30 @@ describe('getLastEdited', function(){ }); }) +describe('appendText', function(){ + it('Append text to a pad Id', function(done) { + api.get(endPoint('appendText', '1.2.13')+"&padID="+testPadId+"&text=hello") + .expect(function(res){ + if(res.body.code !== 0) throw new Error("Pad Append 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 !== text+"\nhello") throw new Error("Pad Text not set properly"); + }) + .expect('Content-Type', /json/) + .expect(200, done); + }); +}); + + describe('setHTML', function(){ it('Sets the HTML of a Pad attempting to pass ugly HTML', function(done) { var html = "<div><b>Hello HTML</title></head></div>"; @@ -542,8 +568,9 @@ describe('createPad', function(){ */ -var endPoint = function(point){ - return '/api/'+apiVersion+'/'+point+'?apikey='+apiKey; +var endPoint = function(point, version){ + version = version || apiVersion; + return '/api/'+version+'/'+point+'?apikey='+apiKey; } function makeid() |