From fa35b555b7988fad4f73c41e94d6cd7b542a78e3 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 20 Feb 2019 16:15:10 +1100 Subject: [PATCH] Correct failing test WARNING: forEach is a trap when async is involved cause it leaks promises for X of Y is a very clean workaround that keeps the code ver readable --- test/javascripts/lib/user-search-test.js.es6 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/javascripts/lib/user-search-test.js.es6 b/test/javascripts/lib/user-search-test.js.es6 index 55b512c9ae9..28e3da7d3c8 100644 --- a/test/javascripts/lib/user-search-test.js.es6 +++ b/test/javascripts/lib/user-search-test.js.es6 @@ -80,10 +80,10 @@ QUnit.test("it skips a search depending on punctuations", async assert => { "@sam:" ]; - skippedTerms.forEach(async term => { + for (let term of skippedTerms) { let results = await userSearch({ term }); assert.equal(results.length, 0); - }); + } let allowedTerms = [ "@sam sam", // double space is not allowed @@ -93,8 +93,8 @@ QUnit.test("it skips a search depending on punctuations", async assert => { let topicId = 100; - allowedTerms.forEach(async term => { + for (let term of allowedTerms) { let results = await userSearch({ term, topicId }); assert.equal(results.length, 6); - }); + } });