From 0d8c698622c6dcfb1e74f1c77550fcc2a747e9aa Mon Sep 17 00:00:00 2001 From: "Peter \"Pita\" Martischka" Date: Wed, 13 Mar 2013 23:14:04 -0700 Subject: [PATCH] Added test for ctrl+z --- tests/frontend/specs/button_undo.js | 33 ---------------- tests/frontend/specs/undo.js | 60 +++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 33 deletions(-) delete mode 100644 tests/frontend/specs/button_undo.js create mode 100644 tests/frontend/specs/undo.js diff --git a/tests/frontend/specs/button_undo.js b/tests/frontend/specs/button_undo.js deleted file mode 100644 index 412b786be..000000000 --- a/tests/frontend/specs/button_undo.js +++ /dev/null @@ -1,33 +0,0 @@ -describe("undo button", function(){ - beforeEach(function(cb){ - helper.newPad(cb); // creates a new pad - this.timeout(60000); - }); - - it("undo some typing", function(done){ - var inner$ = helper.padInner$; - var chrome$ = helper.padChrome$; - - // get the first text element inside the editable space - var $firstTextElement = inner$("div span").first(); - var originalValue = $firstTextElement.text(); // get the original value - - $firstTextElement.sendkeys("foo"); // send line 1 to the pad - var modifiedValue = $firstTextElement.text(); // get the modified value - expect(modifiedValue).not.to.be(originalValue); // expect the value to change - - // get clear authorship button as a variable - var $undoButton = chrome$(".buttonicon-undo"); - // click the button - $undoButton.click(); - - helper.waitFor(function(){ - return inner$("div span").first().text() === originalValue; - }).done(function(){ - var finalValue = inner$("div span").first().text(); - expect(finalValue).to.be(originalValue); // expect the value to change - done(); - }); - }); -}); - diff --git a/tests/frontend/specs/undo.js b/tests/frontend/specs/undo.js new file mode 100644 index 000000000..617d578b0 --- /dev/null +++ b/tests/frontend/specs/undo.js @@ -0,0 +1,60 @@ +describe("undo", function(){ + beforeEach(function(cb){ + helper.newPad(cb); // creates a new pad + this.timeout(60000); + }); + + it("works using the undo button", function(done){ + var inner$ = helper.padInner$; + var chrome$ = helper.padChrome$; + + // get the first text element inside the editable space + var $firstTextElement = inner$("div span").first(); + var originalValue = $firstTextElement.text(); // get the original value + + $firstTextElement.sendkeys("foo"); // send line 1 to the pad + var modifiedValue = $firstTextElement.text(); // get the modified value + expect(modifiedValue).not.to.be(originalValue); // expect the value to change + + // get clear authorship button as a variable + var $undoButton = chrome$(".buttonicon-undo"); + // click the button + $undoButton.click(); + + helper.waitFor(function(){ + return inner$("div span").first().text() === originalValue; + }).done(function(){ + var finalValue = inner$("div span").first().text(); + expect(finalValue).to.be(originalValue); // expect the value to change + done(); + }); + }); + + it("works using ctrl+z", function(done){ + var inner$ = helper.padInner$; + + // get the first text element inside the editable space + var $firstTextElement = inner$("div span").first(); + var originalValue = $firstTextElement.text(); // get the original value + + $firstTextElement.sendkeys("foo"); // send line 1 to the pad + var modifiedValue = $firstTextElement.text(); // get the modified value + expect(modifiedValue).not.to.be(originalValue); // expect the value to change + + // create a ctrl+z keydown event and trigger it + var e = $.Event("keydown"); + e.which = 122; + e.ctrlKey = true; + var $document = inner$(inner$.document); + $document.trigger(e); + + helper.waitFor(function(){ + return inner$("div span").first().text() === originalValue; + }).done(function(){ + var finalValue = inner$("div span").first().text(); + expect(finalValue).to.be(originalValue); // expect the value to change + done(); + }); + }); +}); +