From 210870590ccae385dfe38c688c35654266bf20c2 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Tue, 25 Dec 2018 20:16:41 +0100 Subject: [PATCH] improving cleanup between tests in order to combat the frequent test failures seen recently --- js/test/Helper.js | 8 ++++++-- js/test/Model.js | 9 +++++++-- js/test/UiHelper.js | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/js/test/Helper.js b/js/test/Helper.js index 3043300..eac22fa 100644 --- a/js/test/Helper.js +++ b/js/test/Helper.js @@ -211,6 +211,10 @@ describe('Helper', function () { describe('getCookie', function () { this.timeout(30000); + after(function () { + cleanup(); + }); + jsc.property( 'returns the requested cookie', jsc.nearray(jsc.nearray(common.jscAlnumString())), @@ -245,12 +249,12 @@ describe('Helper', function () { jsc.nearray(common.jscA2zString()), jsc.array(common.jscA2zString()), jsc.array(common.jscQueryString()), - jsc.array(common.jscA2zString()), + 'string', function (schema, address, path, query, fragment) { $.PrivateBin.Helper.reset(); var path = path.join('') + (path.length > 0 ? '/' : ''), expected = schema + '://' + address.join('') + '/' + path, - clean = jsdom('', {url: expected + '?' + query.join('') + '#' + fragment.join('')}), + clean = jsdom('', {url: expected + '?' + query.join('') + '#' + fragment}), result = $.PrivateBin.Helper.baseUri(); clean(); return expected === result; diff --git a/js/test/Model.js b/js/test/Model.js index 18ec8a8..74d1749 100644 --- a/js/test/Model.js +++ b/js/test/Model.js @@ -72,7 +72,7 @@ describe('Model', function () { describe('getPasteId', function () { this.timeout(30000); - before(function () { + beforeEach(function () { $.PrivateBin.Model.reset(); cleanup(); }); @@ -121,6 +121,11 @@ describe('Model', function () { describe('getPasteKey', function () { this.timeout(30000); + beforeEach(function () { + $.PrivateBin.Model.reset(); + cleanup(); + }); + jsc.property( 'returns the fragment of the URL', jsc.nearray(common.jscA2zString()), @@ -183,7 +188,7 @@ describe('Model', function () { }); describe('getTemplate', function () { - before(function () { + beforeEach(function () { $.PrivateBin.Model.reset(); cleanup(); }); diff --git a/js/test/UiHelper.js b/js/test/UiHelper.js index e669e60..817345c 100644 --- a/js/test/UiHelper.js +++ b/js/test/UiHelper.js @@ -6,7 +6,7 @@ describe('UiHelper', function () { // for now we use a mock function to trigger the event describe('historyChange', function () { this.timeout(30000); - before(function () { + beforeEach(function () { $.PrivateBin.Helper.reset(); cleanup(); });