From 3947a2183a73e84e95e42f01c6d8118cf7f0a987 Mon Sep 17 00:00:00 2001 From: Ruslan Hrabovyi Date: Sat, 16 Nov 2019 23:34:53 +0200 Subject: [PATCH] Make sure a proper context applied before DOM helper --- addon-test-support/-private/dsl.js | 3 ++- addon-test-support/-private/run.js | 7 ++----- addon-test-support/extend/action.js | 2 ++ 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/addon-test-support/-private/dsl.js b/addon-test-support/-private/dsl.js index 63ebe2c5..1b97548b 100644 --- a/addon-test-support/-private/dsl.js +++ b/addon-test-support/-private/dsl.js @@ -11,13 +11,14 @@ import { isVisible } from '../properties/is-visible'; import { text } from '../properties/text'; import { value } from '../properties/value'; import { getRoot } from './helpers'; +import { chainable } from './run'; const thenDescriptor = { isDescriptor: true, get() { return function() { // this is a chainable node instance - const { _promise } = getRoot(this).__execution_context__; + const { _promise } = getRoot(chainable(this)).__execution_context__; return _promise.then(...arguments); } diff --git a/addon-test-support/-private/run.js b/addon-test-support/-private/run.js index 261a69b7..cb53da1f 100644 --- a/addon-test-support/-private/run.js +++ b/addon-test-support/-private/run.js @@ -15,13 +15,10 @@ export default function run(node, cb) { const _cb = cb.bind(chainedNode); let executionContext; + const chainedRoot = getRoot(chainedNode); if (isChainedNode(node)) { - executionContext = getRoot(node).__execution_context__; - if (!executionContext) { - executionContext = getRoot(node).__execution_context__ = getExecutionContext(node); - } + executionContext = chainedRoot.__execution_context__; } else { - const chainedRoot = getRoot(chainedNode); executionContext = chainedRoot.__execution_context__ = getExecutionContext(chainedNode); } diff --git a/addon-test-support/extend/action.js b/addon-test-support/extend/action.js index 1e2ea809..daba5aa1 100644 --- a/addon-test-support/extend/action.js +++ b/addon-test-support/extend/action.js @@ -21,6 +21,8 @@ export default function action(fn) { context.key = `${key}(${formattedArgs})`; + getRoot(this).__execution_context__ = context; + return fn.bind(this)(...args); }); }