diff --git a/.gitattributes b/.gitattributes
index daef8b1..3c39546 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -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
diff --git a/js/privatebin.js b/js/privatebin.js
index 3d8ddd1..3db3fae 100644
--- a/js/privatebin.js
+++ b/js/privatebin.js
@@ -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}));
}
/**
diff --git a/js/test.js b/js/test.js
index 66752db..044c6c6 100644
--- a/js/test.js
+++ b/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;
}
);
diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php
index b6e7560..4fbd6c0 100644
--- a/tpl/bootstrap.php
+++ b/tpl/bootstrap.php
@@ -69,7 +69,7 @@ if ($MARKDOWN):
-
+
diff --git a/tpl/page.php b/tpl/page.php
index d774d05..2fa90ce 100644
--- a/tpl/page.php
+++ b/tpl/page.php
@@ -47,7 +47,7 @@ if ($MARKDOWN):
-
+