Skip to content

Commit c852278

Browse files
committed
improving testFocus and testBlur
- added test on anchor element
1 parent 7abcb42 commit c852278

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/Js/EventsTest.php

+11
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ public function testFocus()
5656

5757
$focusBlurDetector->focus();
5858
$this->assertEquals('focused', $focusBlurDetector->getValue());
59+
60+
$focusableAnchor = $this->getAssertSession()->elementExists('css', '.elements a#focusable');
61+
$this->assertEquals('no action detected', $focusableAnchor->getText());
62+
63+
$focusableAnchor->focus();
64+
// checking that we're on same page
65+
$this->getAssertSession()->addressEquals('/js_test.html');
66+
$this->assertEquals('focused', $focusableAnchor->getText());
67+
5968
}
6069

6170
/**
@@ -68,6 +77,8 @@ public function testBlur()
6877
$focusBlurDetector = $this->getAssertSession()->elementExists('css', '.elements input#focus-blur-detector');
6978
$this->assertEquals('no action detected', $focusBlurDetector->getValue());
7079

80+
// focusing before, because blur won't be triggered if HTMLElement is not focused
81+
$focusBlurDetector->focus();
7182
$focusBlurDetector->blur();
7283
$this->assertEquals('blured', $focusBlurDetector->getValue());
7384
}

0 commit comments

Comments
 (0)