diff options
author | diosmosis <diosmosis@users.noreply.github.com> | 2019-01-16 04:10:45 +0300 |
---|---|---|
committer | diosmosis <diosmosis@users.noreply.github.com> | 2019-01-16 04:10:45 +0300 |
commit | 4b15e11ff8f39b200c5ca4fa6a41c97d22a870e9 (patch) | |
tree | 1fc567a1fdac05323f4beefde678a5e511ad74fb /plugins/CoreHome/angularjs/common | |
parent | 40f7b6e2c162bd95f67f8cdc502cc7f5a04f1f89 (diff) |
Add initial unit test for piwik helper.
Diffstat (limited to 'plugins/CoreHome/angularjs/common')
-rw-r--r-- | plugins/CoreHome/angularjs/common/services/piwik-helper.spec.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/plugins/CoreHome/angularjs/common/services/piwik-helper.spec.js b/plugins/CoreHome/angularjs/common/services/piwik-helper.spec.js new file mode 100644 index 0000000000..2e185bdda7 --- /dev/null +++ b/plugins/CoreHome/angularjs/common/services/piwik-helper.spec.js @@ -0,0 +1,40 @@ +/*! + * Piwik - free/libre analytics platform + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ +(function () { + describe('piwikHelper', function() { + var piwikHelper; + + beforeEach(module('piwikApp.service')); + beforeEach(inject(function ($injector) { + piwikHelper = $injector.get('piwik').helper; + })); + beforeEach(function () { + delete window._dosomething; + }); + + describe('#htmlDecode', function () { + + it('should correctly decode html entities', function (done) { + var called = false; + window._dosomething = function () { + called = true; + }; + + var encoded = 'str <img src=\'x/\' onerror=\'_dosomething()\'/>'; + var decoded = piwikHelper.htmlDecode(encoded); + + setTimeout(function () { + expect(called).to.be.false; + expect(decoded).to.equal('str <img src=\'x/\' onerror=\'_dosomething()\'/>'); + done(); + }, 500); + }); + + }); + }); + +})();
\ No newline at end of file |