diff --git a/addon-test-support/-private/execution_context/acceptance.js b/addon-test-support/-private/execution_context/acceptance.js index 0ce998e0..c7322086 100644 --- a/addon-test-support/-private/execution_context/acceptance.js +++ b/addon-test-support/-private/execution_context/acceptance.js @@ -1,4 +1,5 @@ import run from '../run'; +import $ from '-jquery'; import { guardMultiple, buildSelector, @@ -37,6 +38,7 @@ AcceptanceExecutionContext.prototype = { /* global click */ click(element); }, + fillIn(element, content) { /* global focus */ focus(element); @@ -53,28 +55,16 @@ AcceptanceExecutionContext.prototype = { triggerEvent(element, eventName, eventOptions); }, - focus(selector, options) { - let $selection = this.findWithAssert(selector, options); - - assertFocusable($selection[0], { - selector, - pageObjectNode: this.pageObjectNode, - pageObjectKey: options.pageObjectKey - }); + focus(element) { + assertFocusable(element); - $selection.focus(); + $(element).focus(); }, - blur(selector, options) { - let $selection = this.findWithAssert(selector, options); - - assertFocusable($selection[0], { - selector, - pageObjectNode: this.pageObjectNode, - pageObjectKey: options.pageObjectKey - }); + blur(element) { + assertFocusable(element); - $selection.blur(); + $(element).blur(); }, find(selector, options) { diff --git a/addon-test-support/-private/execution_context/helpers.js b/addon-test-support/-private/execution_context/helpers.js index e3cd8409..4ddbc7d1 100644 --- a/addon-test-support/-private/execution_context/helpers.js +++ b/addon-test-support/-private/execution_context/helpers.js @@ -1,5 +1,4 @@ import $ from '-jquery'; -import { throwBetterError } from '../better-errors'; /** * @private @@ -35,7 +34,7 @@ export function fillElement(selection, content) { * * @param {Element} element - the element to check */ -export function assertFocusable(element, { selector, pageObjectNode, pageObjectKey }) { +export function assertFocusable(element) { let $element = $(element); let error; @@ -51,12 +50,6 @@ export function assertFocusable(element, { selector, pageObjectNode, pageObjectK } if (error) { - throwBetterError( - pageObjectNode, - pageObjectKey, - `Element is not focusable because it is ${error}`, { - selector - } - ); + throw new Error(`Element is not focusable because it is ${error}`); } } diff --git a/addon-test-support/-private/execution_context/integration.js b/addon-test-support/-private/execution_context/integration.js index d53dd1db..cc72a2fc 100644 --- a/addon-test-support/-private/execution_context/integration.js +++ b/addon-test-support/-private/execution_context/integration.js @@ -61,28 +61,16 @@ IntegrationExecutionContext.prototype = { $(element).trigger(event); }, - focus(selector, options) { - let $selection = this.findWithAssert(selector, options); + focus(element) { + assertFocusable(element); - assertFocusable($selection[0], { - selector, - pageObjectNode: this.pageObjectNode, - pageObjectKey: options.pageObjectKey - }); - - $selection.focus(); + $(element).focus(); }, - blur(selector, options) { - let $selection = this.findWithAssert(selector, options); - - assertFocusable($selection[0], { - selector, - pageObjectNode: this.pageObjectNode, - pageObjectKey: options.pageObjectKey - }); + blur(element) { + assertFocusable(element); - $selection.blur(); + $(element).blur(); }, find(selector, options) { diff --git a/addon-test-support/-private/execution_context/native-events-context.js b/addon-test-support/-private/execution_context/native-events-context.js index 53de7e13..3f834595 100644 --- a/addon-test-support/-private/execution_context/native-events-context.js +++ b/addon-test-support/-private/execution_context/native-events-context.js @@ -76,26 +76,14 @@ ExecutionContext.prototype = { } }, - focus(selector, options) { - const element = this.findWithAssert(selector, options)[0]; - - assertFocusable(element, { - selector, - pageObjectNode: this.pageObjectNode, - pageObjectKey: options.pageObjectKey - }); + focus(element) { + assertFocusable(element); focus(element); }, - blur(selector, options) { - const element = this.findWithAssert(selector, options)[0]; - - assertFocusable(element, { - selector, - pageObjectNode: this.pageObjectNode, - pageObjectKey: options.pageObjectKey - }); + blur(element) { + assertFocusable(element); blur(element); }, diff --git a/addon-test-support/-private/execution_context/rfc268.js b/addon-test-support/-private/execution_context/rfc268.js index 0031d83e..6bd6bcb9 100644 --- a/addon-test-support/-private/execution_context/rfc268.js +++ b/addon-test-support/-private/execution_context/rfc268.js @@ -51,14 +51,12 @@ ExecutionContext.prototype = { return triggerEvent(element, eventName, eventOptions); }, - focus(selector, options) { - selector = buildSelector(this.pageObjectNode, selector, options); - return this.invokeHelper(selector, options, focus); + focus(element) { + return focus(element); }, - blur(selector, options) { - selector = buildSelector(this.pageObjectNode, selector, options); - return this.invokeHelper(selector, options, blur); + blur(element) { + return blur(element); }, find(selector, options) { diff --git a/addon-test-support/properties/blurrable.js b/addon-test-support/properties/blurrable.js index 377d6bd1..88486ac3 100644 --- a/addon-test-support/properties/blurrable.js +++ b/addon-test-support/properties/blurrable.js @@ -1,5 +1,6 @@ +import run from '../-private/run'; import { assign } from '../-private/helpers'; -import { getExecutionContext } from '../-private/execution_context'; +import { action } from '../extend/index'; /** * @@ -68,11 +69,12 @@ export function blurrable(selector, userOptions = {}) { get(key) { return function() { - const executionContext = getExecutionContext(this); - const options = assign({ pageObjectKey: `${key}()` }, userOptions); + const query = assign({ + pageObjectKey: `${key}()`, + }, userOptions); - return executionContext.runAsync((context) => { - return context.blur(selector, options); + return run(this, ({ blur }) => { + return action(this, selector, query, blur); }); }; } diff --git a/addon-test-support/properties/focusable.js b/addon-test-support/properties/focusable.js index 8f49b83a..3e5437ef 100644 --- a/addon-test-support/properties/focusable.js +++ b/addon-test-support/properties/focusable.js @@ -1,5 +1,6 @@ +import run from '../-private/run'; import { assign } from '../-private/helpers'; -import { getExecutionContext } from '../-private/execution_context'; +import { action } from '../extend/index'; /** * @@ -68,11 +69,12 @@ export function focusable(selector, userOptions = {}) { get(key) { return function() { - const executionContext = getExecutionContext(this); - const options = assign({ pageObjectKey: `${key}()` }, userOptions); + const query = assign({ + pageObjectKey: `${key}()`, + }, userOptions); - return executionContext.runAsync((context) => { - return context.focus(selector, options); + return run(this, ({ focus }) => { + return action(this, selector, query, focus); }); }; }