From d7c80ed41e4bb8ee7bb61adbfd6cc7e36fd00d8e Mon Sep 17 00:00:00 2001 From: johnyma22 Date: Tue, 9 Oct 2012 15:51:55 +0100 Subject: [PATCH] keystroke enter spec --- tests/frontend/specs/keystroke_enter.js | 34 +++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/frontend/specs/keystroke_enter.js diff --git a/tests/frontend/specs/keystroke_enter.js b/tests/frontend/specs/keystroke_enter.js new file mode 100644 index 000000000..4d37f00ec --- /dev/null +++ b/tests/frontend/specs/keystroke_enter.js @@ -0,0 +1,34 @@ +describe("enter keystroke", function(){ + //create a new pad before each test run + beforeEach(function(cb){ + helper.newPad(cb); + this.timeout(5000); + }); + + it("creates a enw line & puts cursor onto a new line", function(done) { + var inner$ = helper.padInner$; + var chrome$ = helper.padChrome$; + + //get the first text element out of the inner iframe + var $firstTextElement = inner$("div").first(); + + // get the original string value minus the last char + var originalTextValue = $firstTextElement.text(); + + // simulate key presses to enter content + $firstTextElement.sendkeys('{enter}'); + + //ace creates a new dom element when you press a keystroke, so just get the first text element again + var $newFirstTextElement = inner$("div").first(); + + helper.waitFor(function(){ + return inner$("div").first().text() === ""; + }).done(function(){ + var $newSecondLine = inner$("div").first().next(); + var newFirstTextElementValue = inner$("div").first().text(); + expect(newFirstTextElementValue).to.be(""); // expect the first line to be blank + expect($newSecondLine.text()).to.be(originalTextValue); // expect the second line to be the same as the original first line. + done(); + }); + }); +});