From 16b0768a93414f02e5d2402d3944f3edbb63bf2c Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sun, 11 Oct 2020 21:48:40 -0400 Subject: [PATCH] tests: Fix unchainable `helper.waitFor().fail()` The `helper.waitFor()` function returns a jQuery Deferred object. Deferred objects are supposed to have a `.fail()` method that is chainable (it should return `this`). Before this change, `helper.waitFor()` monkey-patched the `.fail()` method with a function that returned `undefined`. Now the monkey-patched `.fail()` returns the Deferred object. Also modernize the code a bit. --- tests/frontend/helper.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/frontend/helper.js b/tests/frontend/helper.js index e14169bb1..f36e45692 100644 --- a/tests/frontend/helper.js +++ b/tests/frontend/helper.js @@ -164,12 +164,12 @@ var helper = {}; var deferred = $.Deferred(); - var _fail = deferred.fail; + const _fail = deferred.fail.bind(deferred); var listenForFail = false; - deferred.fail = function(){ + deferred.fail = (...args) => { listenForFail = true; - _fail.apply(this, arguments); - } + return _fail(...args); + }; var intervalCheck = setInterval(function(){ var passed = false;