Skip to content

Commit e886c01

Browse files
authored
Merge pull request #29 from hyperdivision/blur
Add a blur method
2 parents 31ee0c4 + 1a13e60 commit e886c01

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ Accepts a query selector string that resolves to an element or an element. Call
186186

187187
Accepts a query selector string that resolves to an element or an element. Calls `element.focus()` followed by a `t.delay()`.
188188

189+
### `await t.blur(elementOrQuerySelector, [msg])`
190+
191+
Accepts a query selector string that resolves to an element or an element. Calls `element.blur()` followed by a `t.delay()`.
192+
189193
### `await t.type(string, [event], [msg])`
190194

191195
Dispatches `new window.KeyboardEvent` defaulting to the `keydown` event, for each character in `string`. Helpful for typing into the currently focused element on screen. This helper is a WIP, and doesn't work everywhere. Includes a `t.delay()` call so updates are rendered every keypress.

index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ function create (delay, fn) {
9797
toElement(stringOrElement).focus()
9898
return t.delay().then(() => t.pass(msg))
9999
},
100+
blur (stringOrElement, msg) {
101+
msg = msg || `Blurred from ${typeof stringOrElement === 'string' ? stringOrElement : 'element'}`
102+
toElement(stringOrElement).blur()
103+
return t.delay().then(() => t.pass(msg))
104+
},
100105
async type (str, event, msg) {
101106
if (typeof event === 'string' && !msg) {
102107
msg = event

0 commit comments

Comments
 (0)