From 9f01ccc80e313a7eb59966a0cd5fc05cccd3c8a3 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Mon, 22 May 2017 22:15:13 +0200 Subject: [PATCH 1/2] added tests for getExpirationDefault() --- js/test.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/js/test.js b/js/test.js index c6e5c7a6..3f24a2eb 100644 --- a/js/test.js +++ b/js/test.js @@ -561,6 +561,40 @@ describe('CryptTool', function () { }); describe('Model', function () { + describe('getExpirationDefault', function () { + before(function () { + $.PrivateBin.Model.reset(); + cleanup(); + }); + + jsc.property( + 'returns the contents of the element with id "pasteExpiration"', + 'array asciinestring', + 'string', + 'small nat', + function (keys, value, key) { + keys = keys.map($.PrivateBin.Helper.htmlEntities); + value = $.PrivateBin.Helper.htmlEntities(value); + var content = keys.length > key ? keys[key] : (keys.length > 0 ? keys[0] : 'null'), + contents = ''; + $('body').html(contents); + var result = $.PrivateBin.Helper.htmlEntities( + $.PrivateBin.Model.getExpirationDefault() + ); + $.PrivateBin.Model.reset(); + return content === result; + } + ); + }); + describe('getPasteId', function () { before(function () { $.PrivateBin.Model.reset(); From 5c3e2b3fae1949bfd19cac56ab9e6d2284d19baf Mon Sep 17 00:00:00 2001 From: El RIDO Date: Mon, 22 May 2017 22:34:12 +0200 Subject: [PATCH 2/2] fix travis once more, this time due to jsdom breaking compatibility with nodeJS < 6 --- .travis.yml | 2 +- tst/README.md | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 79987186..b18d048e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ before_script: - composer install -n - npm install -g mocha - cd js - - npm install jsverify jsdom jsdom-global + - npm install jsverify jsdom@9 jsdom-global@2 - cd .. script: diff --git a/tst/README.md b/tst/README.md index e11bc495..00c83855 100644 --- a/tst/README.md +++ b/tst/README.md @@ -51,7 +51,7 @@ and jsdom-global locally: ```console $ npm install -g mocha istanbul $ cd PrivateBin/js -$ npm install jsverify jsdom jsdom-global +$ npm install jsverify jsdom@9 jsdom-global@2 ``` Example for Debian and Ubuntu, including steps to allow the current user to @@ -63,9 +63,12 @@ $ sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share} $ ln -s /usr/bin/nodejs /usr/local/bin/node $ npm install -g mocha istanbul $ cd PrivateBin/js -$ npm install jsverify jsdom jsdom-global +$ npm install jsverify jsdom@9 jsdom-global@2 ``` +Note: If you use a distribution that provides nodeJS >= 6, then you can install +the latest jsdom and jsdom-global packages and don't need to use @9 and @2. + To run the tests, just change into the `js` directory and run istanbul: ```console $ cd PrivateBin/js