diff options
author | Xavid <xavid@mit.edu> | 2015-06-30 04:47:55 -0400 |
---|---|---|
committer | Xavid <xavid@mit.edu> | 2015-06-30 04:47:55 -0400 |
commit | ad137fa4c876f9d7dc2d8113d8bcef9b9425ce0c (patch) | |
tree | 74f82ba67999d1dd718802fbe1dbdccb302d88b6 /tests | |
parent | d803ac128ecae61402d98bdf14f547c5fd52a1c4 (diff) | |
download | etherpad-lite-ad137fa4c876f9d7dc2d8113d8bcef9b9425ce0c.zip |
Restore newline-adding to setText() if passed string does not end in '\n'.
Add a test for the ending-in-'\n' case and update tests for the other case.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/backend/specs/api/pad.js | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/tests/backend/specs/api/pad.js b/tests/backend/specs/api/pad.js index 1b6e883a..14e99091 100644 --- a/tests/backend/specs/api/pad.js +++ b/tests/backend/specs/api/pad.js @@ -211,7 +211,7 @@ describe('getText', function(){ it('gets the Pad text', function(done) { api.get(endPoint('getText')+"&padID="+testPadId) .expect(function(res){ - if(res.body.data.text !== "testTextTwo") throw new Error("Setting Text") + if(res.body.data.text !== "testTextTwo\n") throw new Error("Setting Text") }) .expect('Content-Type', /json/) .expect(200, done) @@ -387,7 +387,30 @@ describe('getText', function(){ 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) throw new Error("Pad Text not set properly"); + if(res.body.data.text !== text+"\n") throw new Error("Pad Text not set properly"); + }) + .expect('Content-Type', /json/) + .expect(200, done) + }); +}) + +describe('setText', function(){ + it('Sets text on a pad Id including an explicit newline', function(done) { + api.get(endPoint('setText')+"&padID="+testPadId+"&text="+text+'%0A') + .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 and doesn't have an excess newline", 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+"\n") throw new Error("Pad Text not set properly"); }) .expect('Content-Type', /json/) .expect(200, done) @@ -420,7 +443,7 @@ 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 !== text) throw new Error("Pad Get Text failed") + if(res.body.data.text !== text+"\n") throw new Error("Pad Get Text failed") }) .expect('Content-Type', /json/) .expect(200, done) @@ -442,7 +465,7 @@ 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 !== text) throw new Error("Pad Get Text failed") + if(res.body.data.text !== text+"\n") throw new Error("Pad Get Text failed") }) .expect('Content-Type', /json/) .expect(200, done) |