From 3fba2c381df53130fe1777f6bef58cf801890197 Mon Sep 17 00:00:00 2001 From: Tom Byers Date: Fri, 8 Nov 2019 12:39:41 +0000 Subject: [PATCH] Make screenMock helper mock more DOM APIs jQuery 3 also calls `.getClientRects` to get the position and dimension of elements. --- tests/javascripts/support/helpers/rendering.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/javascripts/support/helpers/rendering.js b/tests/javascripts/support/helpers/rendering.js index 5d3fdd2d2..673998047 100644 --- a/tests/javascripts/support/helpers/rendering.js +++ b/tests/javascripts/support/helpers/rendering.js @@ -214,8 +214,10 @@ class ScreenRenderItem { // mock any calls to the node's DOM API for position/dimension _mockAPICalls () { - // proxy boundingClientRect property calls to item data + // proxy getBoundingClientRect and getClientRects calls to item data + // assumes getClientRects only returns one clientRect this._jest.spyOn(this._node, 'getBoundingClientRect').mockImplementation(() => this._getBoundingClientRect()); + this._jest.spyOn(this._node, 'getClientRects').mockImplementation(() => [this._getBoundingClientRect()]); // handle calls to offset properties ScreenRenderItem.OFFSET_PROPS.forEach(prop => {