From ba0ff3545d4b4ef4c50d4c20da60bdef9580a4dc Mon Sep 17 00:00:00 2001 From: El RIDO Date: Wed, 13 Sep 2017 07:23:56 +0200 Subject: [PATCH] started work on UiHelper tests --- js/test.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/js/test.js b/js/test.js index f0a4c47..fce63c6 100644 --- a/js/test.js +++ b/js/test.js @@ -2,6 +2,7 @@ var jsc = require('jsverify'), jsdom = require('jsdom-global'), cleanup = jsdom(), + EventEmitter = require('events'), a2zString = ['a','b','c','d','e','f','g','h','i','j','k','l','m', 'n','o','p','q','r','s','t','u','v','w','x','y','z'], @@ -810,3 +811,32 @@ describe('Model', function () { ); }); }); + +describe('UiHelper', function () { + describe('historyChange', function () { + before(function () { + $.PrivateBin.Helper.reset(); + }); + + jsc.property( + 'returns the URL without query & fragment', + jsc.elements(schemas), + jsc.nearray(jsc.elements(a2zString)), + jsc.array(jsc.elements(queryString)), + 'string', + function (schema, address, query, fragment) { + var expected = schema + '://' + address.join('') + '/', + clean = jsdom('', {url: expected + '?' + query.join('') + '#' + fragment}), + emitter = new EventEmitter(); + + $.PrivateBin.UiHelper.init(); + emitter.emit('popstate'); + var result = window.location.href; + clean(); + console.log(expected, result); + return expected === result; + } + ); + }); +}); +