summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorjohnyma22 <john@mclear.co.uk>2012-10-03 21:25:31 +0100
committerjohnyma22 <john@mclear.co.uk>2012-10-03 21:25:31 +0100
commit339ee6d2e09963a88f9d8a77c0ffd73c17dda32e (patch)
treec7a6dc25dcf72f13eb0afdb660c10cae68a99888 /tests
parentaa41ebcd6d0188209ac50f7a5521cf4051abc701 (diff)
downloadetherpad-lite-339ee6d2e09963a88f9d8a77c0ffd73c17dda32e.zip
working keystroke delete check
Diffstat (limited to 'tests')
-rw-r--r--tests/frontend/specs/keystroke_delete.js30
1 files changed, 10 insertions, 20 deletions
diff --git a/tests/frontend/specs/keystroke_delete.js b/tests/frontend/specs/keystroke_delete.js
index bd070253..58a6b5bb 100644
--- a/tests/frontend/specs/keystroke_delete.js
+++ b/tests/frontend/specs/keystroke_delete.js
@@ -11,38 +11,28 @@ describe("delete keystroke", function(){
//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");
+ // get the original string value minus the last char
+ var originalTextValue = firstTextElement.text();
+ originalTextValue = originalTextValue.substring(0, originalTextValue.length -1);
- //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
+ // simulate key presses to delete content
+ firstTextElement.sendkeys('{leftarrow}'); // simulate a keypress of the left arrow key
+ firstTextElement.sendkeys('{del}'); // simulate a keypress of delete
//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 it to be one char less in length
expect(newElementLength).to.be((elementLength-1));
- //make sure the text hasn't changed
- expect(newFirstTextElement.text()).to.eql(firstTextElement.text());
+ //make sure the text has changed correctly
+ expect(newFirstTextElement.text()).to.eql(originalTextValue);
+
});
});