summaryrefslogtreecommitdiff
path: root/tests/frontend/specs/keystroke_delete.js
diff options
context:
space:
mode:
authorjohnyma22 <john@mclear.co.uk>2012-10-03 20:57:04 +0100
committerjohnyma22 <john@mclear.co.uk>2012-10-03 20:57:04 +0100
commit7820e3eb7c68971650909fcbd11336f1821fd0d9 (patch)
tree8749719038aca7c693f752b67911f9424722f76d /tests/frontend/specs/keystroke_delete.js
parent54a77458d604b3225c4ac92dc8c1edcda8250c91 (diff)
downloadetherpad-lite-7820e3eb7c68971650909fcbd11336f1821fd0d9.zip
beginning of keystroke test
Diffstat (limited to 'tests/frontend/specs/keystroke_delete.js')
-rw-r--r--tests/frontend/specs/keystroke_delete.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/frontend/specs/keystroke_delete.js b/tests/frontend/specs/keystroke_delete.js
new file mode 100644
index 00000000..bd070253
--- /dev/null
+++ b/tests/frontend/specs/keystroke_delete.js
@@ -0,0 +1,48 @@
+describe("delete keystroke", function(){
+ //create a new pad before each test run
+ beforeEach(function(cb){
+ testHelper.newPad(cb);
+ });
+
+ it("makes text delete", function() {
+ //get the inner iframe
+ var $inner = testHelper.$getPadInner();
+
+ //get the first text element out of the inner iframe
+ var firstTextElement = $inner.find("div").first();
+
+ //select this text element
+ testHelper.selectText(firstTextElement[0]);
+
+ // get the original length of this element
+ var elementLength = firstTextElement.html().length;
+ console.log(elementLength);
+
+ //get the bold keystroke and click it
+ // var $deletekeystroke = testHelper.$getPadChrome().find(".keystrokeicon-delete");
+
+ //put the cursor in the pad
+ var press = $.Event("keypress");
+ press.ctrlKey = false;
+ press.which = 46; // 46 is delete key
+ firstTextElement.trigger(press); // simulate a keypress of delete
+ press.which = 37; // 37 is left key taking user to first place in pad.
+ firstTextElement.trigger(press); // simulate a keypress of left key
+
+ //ace creates a new dom element when you press a keystroke, so just get the first text element again
+ var newFirstTextElement = $inner.find("div").first();
+
+ // is there a <b> element now?
+ // var isdelete = newFirstTextElement.find("i").length === 1;
+
+ // get the new length of this element
+ var newElementLength = newFirstTextElement.html().length;
+ console.log(newElementLength);
+
+ //expect it to be one char less
+ expect(newElementLength).to.be((elementLength-1));
+
+ //make sure the text hasn't changed
+ expect(newFirstTextElement.text()).to.eql(firstTextElement.text());
+ });
+});