adding tests for UiHelper.reloadHome, making UiHelper unit testable and handling JSVerify RNG states 846932d5afb10ce748 & 012c1f9483adb6e750
This commit is contained in:
parent
cbcc26ec37
commit
4410ddcd84
@ -845,11 +845,9 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||||||
* everything directly UI-related, which fits nowhere else
|
* everything directly UI-related, which fits nowhere else
|
||||||
*
|
*
|
||||||
* @name UiHelper
|
* @name UiHelper
|
||||||
* @param {object} window
|
|
||||||
* @param {object} document
|
|
||||||
* @class
|
* @class
|
||||||
*/
|
*/
|
||||||
var UiHelper = (function (window, document) {
|
var UiHelper = (function () {
|
||||||
var me = {};
|
var me = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -990,7 +988,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return me;
|
return me;
|
||||||
})(window, document);
|
})();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alert/error manager
|
* Alert/error manager
|
||||||
|
46
js/test.js
46
js/test.js
@ -803,8 +803,8 @@ describe('Model', function () {
|
|||||||
element = element.join('');
|
element = element.join('');
|
||||||
value = value.join('').trim();
|
value = value.join('').trim();
|
||||||
|
|
||||||
// <br> tags can't contain strings, so test with a <p> instead
|
// <br> tags can't contain strings, table tags can't be alone, so test with a <p> instead
|
||||||
if (element == 'br') {
|
if (['br', 'tr', 'td', 'th'].indexOf(element) >= 0) {
|
||||||
element = 'p';
|
element = 'p';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -840,7 +840,13 @@ describe('UiHelper', function () {
|
|||||||
var expected = schema + '://' + address.join('') + '/',
|
var expected = schema + '://' + address.join('') + '/',
|
||||||
clean = jsdom('', {url: expected});
|
clean = jsdom('', {url: expected});
|
||||||
|
|
||||||
|
// make window.location.href writable
|
||||||
|
Object.defineProperty(window.location, 'href', {
|
||||||
|
writable: true,
|
||||||
|
value: window.location.href
|
||||||
|
});
|
||||||
$.PrivateBin.UiHelper.mockHistoryChange();
|
$.PrivateBin.UiHelper.mockHistoryChange();
|
||||||
|
$.PrivateBin.Helper.reset();
|
||||||
var result = window.location.href;
|
var result = window.location.href;
|
||||||
clean();
|
clean();
|
||||||
return expected === result;
|
return expected === result;
|
||||||
@ -857,7 +863,43 @@ describe('UiHelper', function () {
|
|||||||
var expected = schema + '://' + address.join('') + '/' + '?' + query.join('') + '#' + fragment.join(''),
|
var expected = schema + '://' + address.join('') + '/' + '?' + query.join('') + '#' + fragment.join(''),
|
||||||
clean = jsdom('', {url: expected});
|
clean = jsdom('', {url: expected});
|
||||||
|
|
||||||
|
// make window.location.href writable
|
||||||
|
Object.defineProperty(window.location, 'href', {
|
||||||
|
writable: true,
|
||||||
|
value: window.location.href
|
||||||
|
});
|
||||||
$.PrivateBin.UiHelper.mockHistoryChange([{type: 'newpaste'}, '', expected]);
|
$.PrivateBin.UiHelper.mockHistoryChange([{type: 'newpaste'}, '', expected]);
|
||||||
|
$.PrivateBin.Helper.reset();
|
||||||
|
var result = window.location.href;
|
||||||
|
clean();
|
||||||
|
return expected === result;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('reloadHome', function () {
|
||||||
|
this.timeout(30000);
|
||||||
|
before(function () {
|
||||||
|
$.PrivateBin.Helper.reset();
|
||||||
|
});
|
||||||
|
|
||||||
|
jsc.property(
|
||||||
|
'redirects to home',
|
||||||
|
jsc.elements(schemas),
|
||||||
|
jsc.nearray(jsc.elements(a2zString)),
|
||||||
|
jsc.array(jsc.elements(queryString)),
|
||||||
|
jsc.nearray(jsc.elements(base64String)),
|
||||||
|
function (schema, address, query, fragment) {
|
||||||
|
var expected = schema + '://' + address.join('') + '/',
|
||||||
|
clean = jsdom('', {url: expected + '?' + query.join('') + '#' + fragment.join('')});
|
||||||
|
|
||||||
|
// make window.location.href writable
|
||||||
|
Object.defineProperty(window.location, 'href', {
|
||||||
|
writable: true,
|
||||||
|
value: window.location.href
|
||||||
|
});
|
||||||
|
$.PrivateBin.UiHelper.reloadHome();
|
||||||
|
$.PrivateBin.Helper.reset();
|
||||||
var result = window.location.href;
|
var result = window.location.href;
|
||||||
clean();
|
clean();
|
||||||
return expected === result;
|
return expected === result;
|
||||||
|
@ -69,7 +69,7 @@ if ($MARKDOWN):
|
|||||||
<?php
|
<?php
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-m9jvM3XYbrYmKTg/UNhGytuBsMQ7t6V/s/IdCUJa0UNH459k4ryJgYc/zVAOjgTddE3KZ7yZ406XJ9Fud1wJbg==" crossorigin="anonymous"></script>
|
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-4wDVRrjzsIYI5/4PF12083H7ydSCC9QPB5s/RyWdE3MnEw88qgbCyt+upI9xkP8p8Y6YCEy4HSfqtJfFxIqXgg==" crossorigin="anonymous"></script>
|
||||||
<!--[if lt IE 10]>
|
<!--[if lt IE 10]>
|
||||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
@ -47,7 +47,7 @@ if ($MARKDOWN):
|
|||||||
<?php
|
<?php
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-m9jvM3XYbrYmKTg/UNhGytuBsMQ7t6V/s/IdCUJa0UNH459k4ryJgYc/zVAOjgTddE3KZ7yZ406XJ9Fud1wJbg==" crossorigin="anonymous"></script>
|
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-4wDVRrjzsIYI5/4PF12083H7ydSCC9QPB5s/RyWdE3MnEw88qgbCyt+upI9xkP8p8Y6YCEy4HSfqtJfFxIqXgg==" crossorigin="anonymous"></script>
|
||||||
<!--[if lt IE 10]>
|
<!--[if lt IE 10]>
|
||||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
Loading…
Reference in New Issue
Block a user