From ad137fa4c876f9d7dc2d8113d8bcef9b9425ce0c Mon Sep 17 00:00:00 2001 From: Xavid Date: Tue, 30 Jun 2015 04:47:55 -0400 Subject: 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. --- tests/backend/specs/api/pad.js | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'tests') 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) -- cgit v1.2.3