mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2024-12-28 20:55:39 +01:00
testing both cases of the logic required for #167
This commit is contained in:
parent
6dbb098d7a
commit
414693fa90
5 changed files with 30 additions and 14 deletions
2
.gitattributes
vendored
2
.gitattributes
vendored
|
@ -2,8 +2,6 @@ doc/ export-ignore
|
|||
tst/ export-ignore
|
||||
js/.istanbul.yml export-ignore
|
||||
js/test.js export-ignore
|
||||
js/mocha-3.2.0.js export-ignore
|
||||
css/mocha-3.2.0.css export-ignore
|
||||
.codeclimate.yml export-ignore
|
||||
.csslintrc export-ignore
|
||||
.dockerignore export-ignore
|
||||
|
|
|
@ -965,10 +965,14 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||
*
|
||||
* @name UiHelper.mockHistoryChange
|
||||
* @function
|
||||
* @param {string} state (optional) state to mock
|
||||
*/
|
||||
me.mockHistoryChange = function()
|
||||
me.mockHistoryChange = function(state)
|
||||
{
|
||||
historyChange($.Event('popstate', {originalEvent: new PopStateEvent('popstate', {state: null}), target: window}));
|
||||
if (typeof state === 'undefined') {
|
||||
state = null;
|
||||
}
|
||||
historyChange($.Event('popstate', {originalEvent: new PopStateEvent('popstate', {state: state}), target: window}));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
30
js/test.js
30
js/test.js
|
@ -818,27 +818,41 @@ describe('Model', function () {
|
|||
});
|
||||
|
||||
describe('UiHelper', function () {
|
||||
// TODO: As per https://github.com/tmpvar/jsdom/issues/1565 there is no navigation support in jsdom, yet.
|
||||
// for now we use a mock function to trigger the event
|
||||
describe('historyChange', function () {
|
||||
before(function () {
|
||||
$.PrivateBin.Helper.reset();
|
||||
});
|
||||
|
||||
// TODO: As per https://github.com/tmpvar/jsdom/issues/1565 there is no navigation support in jsdom, yet.
|
||||
// for now we use a mock function to trigger the event
|
||||
jsc.property(
|
||||
'returns the URL without query & fragment',
|
||||
'redirects to home, when the state is null',
|
||||
jsc.elements(schemas),
|
||||
jsc.nearray(jsc.elements(a2zString)),
|
||||
jsc.array(jsc.elements(queryString)),
|
||||
'string',
|
||||
function (schema, address, query, fragment) {
|
||||
function (schema, address) {
|
||||
var expected = schema + '://' + address.join('') + '/',
|
||||
clean = jsdom('', {url: expected + '?' + query.join('') + '#' + fragment});
|
||||
clean = jsdom('', {url: expected});
|
||||
|
||||
$.PrivateBin.UiHelper.mockHistoryChange();
|
||||
var result = window.location.href;
|
||||
clean();
|
||||
console.log(expected, result);
|
||||
return expected === result;
|
||||
}
|
||||
);
|
||||
|
||||
jsc.property(
|
||||
'does not redirect to home, when a new paste is created',
|
||||
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('') + '/' + '?' + query.join('') + '#' + fragment.join(''),
|
||||
clean = jsdom('', {url: expected});
|
||||
|
||||
$.PrivateBin.UiHelper.mockHistoryChange([{type: 'newpaste'}, '', expected]);
|
||||
var result = window.location.href;
|
||||
clean();
|
||||
return expected === result;
|
||||
}
|
||||
);
|
||||
|
|
|
@ -69,7 +69,7 @@ if ($MARKDOWN):
|
|||
<?php
|
||||
endif;
|
||||
?>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-08YP16cuZ9x9zHHsPLEnAQU2vD8xXFGD0KYfYZeRkje8hSUhf/j1F1ifWKZCVoZST2XXA1PJjnVHTcKxeWAGNA==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-m9jvM3XYbrYmKTg/UNhGytuBsMQ7t6V/s/IdCUJa0UNH459k4ryJgYc/zVAOjgTddE3KZ7yZ406XJ9Fud1wJbg==" crossorigin="anonymous"></script>
|
||||
<!--[if lt IE 10]>
|
||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||
<![endif]-->
|
||||
|
|
|
@ -47,7 +47,7 @@ if ($MARKDOWN):
|
|||
<?php
|
||||
endif;
|
||||
?>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-08YP16cuZ9x9zHHsPLEnAQU2vD8xXFGD0KYfYZeRkje8hSUhf/j1F1ifWKZCVoZST2XXA1PJjnVHTcKxeWAGNA==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-m9jvM3XYbrYmKTg/UNhGytuBsMQ7t6V/s/IdCUJa0UNH459k4ryJgYc/zVAOjgTddE3KZ7yZ406XJ9Fud1wJbg==" crossorigin="anonymous"></script>
|
||||
<!--[if lt IE 10]>
|
||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||
<![endif]-->
|
||||
|
|
Loading…
Reference in a new issue