aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/dom_tests/dom_tests.coffee26
-rw-r--r--tests/dom_tests/phantom_runner.coffee3
2 files changed, 29 insertions, 0 deletions
diff --git a/tests/dom_tests/dom_tests.coffee b/tests/dom_tests/dom_tests.coffee
index c3bdb9c5..84942908 100644
--- a/tests/dom_tests/dom_tests.coffee
+++ b/tests/dom_tests/dom_tests.coffee
@@ -996,3 +996,29 @@ context "PostFindMode",
sendKeyboardEvent "escape"
assert.isTrue @postFindMode.modeIsActive
+context "WaitForEnter",
+ setup ->
+ initializeModeState()
+ @isSuccess = null
+ @waitForEnter = new WaitForEnter (isSuccess) => @isSuccess = isSuccess
+
+ should "exit with success on Enter", ->
+ assert.isTrue @waitForEnter.modeIsActive
+ assert.isFalse @isSuccess?
+ sendKeyboardEvent "enter"
+ assert.isFalse @waitForEnter.modeIsActive
+ assert.isTrue @isSuccess? and @isSuccess == true
+
+ should "exit without success on Escape", ->
+ assert.isTrue @waitForEnter.modeIsActive
+ assert.isFalse @isSuccess?
+ sendKeyboardEvent "escape"
+ assert.isFalse @waitForEnter.modeIsActive
+ assert.isTrue @isSuccess? and @isSuccess == false
+
+ should "not exit on other keyboard events", ->
+ assert.isTrue @waitForEnter.modeIsActive
+ assert.isFalse @isSuccess?
+ sendKeyboardEvents "abc"
+ assert.isTrue @waitForEnter.modeIsActive
+ assert.isFalse @isSuccess?
diff --git a/tests/dom_tests/phantom_runner.coffee b/tests/dom_tests/phantom_runner.coffee
index 265c994e..09d7d584 100644
--- a/tests/dom_tests/phantom_runner.coffee
+++ b/tests/dom_tests/phantom_runner.coffee
@@ -28,6 +28,9 @@ page.onCallback = (request) ->
when "escape"
page.sendEvent "keydown", page.event.key.Escape
page.sendEvent "keyup", page.event.key.Escape
+ when "enter"
+ page.sendEvent "keydown", page.event.key.Enter
+ page.sendEvent "keyup", page.event.key.Enter
when "tab"
page.sendEvent "keydown", page.event.key.Tab
page.sendEvent "keyup", page.event.key.Tab