|
@@ -20,7 +20,7 @@ global.RawDeflate = require('./rawdeflate-0.5');
|
|
|
require('./rawinflate-0.3');
|
|
require('./rawinflate-0.3');
|
|
|
require('./privatebin');
|
|
require('./privatebin');
|
|
|
|
|
|
|
|
-describe('helper', function () {
|
|
|
|
|
|
|
+describe('Helper', function () {
|
|
|
describe('secondsToHuman', function () {
|
|
describe('secondsToHuman', function () {
|
|
|
after(function () {
|
|
after(function () {
|
|
|
cleanup();
|
|
cleanup();
|
|
@@ -66,7 +66,7 @@ describe('helper', function () {
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- describe('scriptLocation', function () {
|
|
|
|
|
|
|
+ describe('baseUri', function () {
|
|
|
jsc.property(
|
|
jsc.property(
|
|
|
'returns the URL without query & fragment',
|
|
'returns the URL without query & fragment',
|
|
|
jsc.nearray(jsc.elements(a2zString)),
|
|
jsc.nearray(jsc.elements(a2zString)),
|
|
@@ -76,19 +76,36 @@ describe('helper', function () {
|
|
|
function (schema, address, query, fragment) {
|
|
function (schema, address, query, fragment) {
|
|
|
var expected = schema.join('') + '://' + address.join('') + '/',
|
|
var expected = schema.join('') + '://' + address.join('') + '/',
|
|
|
clean = jsdom('', {url: expected + '?' + query.join('') + '#' + fragment}),
|
|
clean = jsdom('', {url: expected + '?' + query.join('') + '#' + fragment}),
|
|
|
- result = $.PrivateBin.Helper.scriptLocation();
|
|
|
|
|
|
|
+ result = $.PrivateBin.Helper.baseUri();
|
|
|
clean();
|
|
clean();
|
|
|
return expected === result;
|
|
return expected === result;
|
|
|
}
|
|
}
|
|
|
);
|
|
);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- describe('pasteId', function () {
|
|
|
|
|
|
|
+ describe('htmlEntities', function () {
|
|
|
|
|
+ after(function () {
|
|
|
|
|
+ cleanup();
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ jsc.property(
|
|
|
|
|
+ 'removes all HTML entities from any given string',
|
|
|
|
|
+ 'string',
|
|
|
|
|
+ function (string) {
|
|
|
|
|
+ var result = $.PrivateBin.Helper.htmlEntities(string);
|
|
|
|
|
+ return !(/[<>"'`=\/]/.test(result)) && !(string.indexOf('&') > -1 && !(/&/.test(result)));
|
|
|
|
|
+ }
|
|
|
|
|
+ );
|
|
|
|
|
+ });
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+describe('Model', function () {
|
|
|
|
|
+ describe('getPasteId', function () {
|
|
|
jsc.property(
|
|
jsc.property(
|
|
|
'returns the query string without separator, if any',
|
|
'returns the query string without separator, if any',
|
|
|
jsc.nearray(jsc.elements(a2zString)),
|
|
jsc.nearray(jsc.elements(a2zString)),
|
|
|
jsc.nearray(jsc.elements(a2zString)),
|
|
jsc.nearray(jsc.elements(a2zString)),
|
|
|
- jsc.array(jsc.elements(queryString)),
|
|
|
|
|
|
|
+ jsc.nearray(jsc.elements(queryString)),
|
|
|
'string',
|
|
'string',
|
|
|
function (schema, address, query, fragment) {
|
|
function (schema, address, query, fragment) {
|
|
|
var queryString = query.join(''),
|
|
var queryString = query.join(''),
|
|
@@ -96,27 +113,29 @@ describe('helper', function () {
|
|
|
url: schema.join('') + '://' + address.join('') +
|
|
url: schema.join('') + '://' + address.join('') +
|
|
|
'/?' + queryString + '#' + fragment
|
|
'/?' + queryString + '#' + fragment
|
|
|
}),
|
|
}),
|
|
|
- result = $.PrivateBin.Helper.pasteId();
|
|
|
|
|
|
|
+ result = $.PrivateBin.Model.getPasteId();
|
|
|
|
|
+ $.PrivateBin.Model.reset();
|
|
|
clean();
|
|
clean();
|
|
|
return queryString === result;
|
|
return queryString === result;
|
|
|
}
|
|
}
|
|
|
);
|
|
);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- describe('pageKey', function () {
|
|
|
|
|
|
|
+ describe('getPasteKey', function () {
|
|
|
jsc.property(
|
|
jsc.property(
|
|
|
'returns the fragment of the URL',
|
|
'returns the fragment of the URL',
|
|
|
jsc.nearray(jsc.elements(a2zString)),
|
|
jsc.nearray(jsc.elements(a2zString)),
|
|
|
jsc.nearray(jsc.elements(a2zString)),
|
|
jsc.nearray(jsc.elements(a2zString)),
|
|
|
jsc.array(jsc.elements(queryString)),
|
|
jsc.array(jsc.elements(queryString)),
|
|
|
- jsc.array(jsc.elements(base64String)),
|
|
|
|
|
|
|
+ jsc.nearray(jsc.elements(base64String)),
|
|
|
function (schema, address, query, fragment) {
|
|
function (schema, address, query, fragment) {
|
|
|
var fragmentString = fragment.join(''),
|
|
var fragmentString = fragment.join(''),
|
|
|
clean = jsdom('', {
|
|
clean = jsdom('', {
|
|
|
url: schema.join('') + '://' + address.join('') +
|
|
url: schema.join('') + '://' + address.join('') +
|
|
|
'/?' + query.join('') + '#' + fragmentString
|
|
'/?' + query.join('') + '#' + fragmentString
|
|
|
}),
|
|
}),
|
|
|
- result = $.PrivateBin.Modal.getPasteKey();
|
|
|
|
|
|
|
+ result = $.PrivateBin.Model.getPasteKey();
|
|
|
|
|
+ $.PrivateBin.Model.reset();
|
|
|
clean();
|
|
clean();
|
|
|
return fragmentString === result;
|
|
return fragmentString === result;
|
|
|
}
|
|
}
|
|
@@ -126,7 +145,7 @@ describe('helper', function () {
|
|
|
jsc.nearray(jsc.elements(a2zString)),
|
|
jsc.nearray(jsc.elements(a2zString)),
|
|
|
jsc.nearray(jsc.elements(a2zString)),
|
|
jsc.nearray(jsc.elements(a2zString)),
|
|
|
jsc.array(jsc.elements(queryString)),
|
|
jsc.array(jsc.elements(queryString)),
|
|
|
- jsc.array(jsc.elements(base64String)),
|
|
|
|
|
|
|
+ jsc.nearray(jsc.elements(base64String)),
|
|
|
jsc.array(jsc.elements(queryString)),
|
|
jsc.array(jsc.elements(queryString)),
|
|
|
function (schema, address, query, fragment, trail) {
|
|
function (schema, address, query, fragment, trail) {
|
|
|
var fragmentString = fragment.join(''),
|
|
var fragmentString = fragment.join(''),
|
|
@@ -134,25 +153,11 @@ describe('helper', function () {
|
|
|
url: schema.join('') + '://' + address.join('') + '/?' +
|
|
url: schema.join('') + '://' + address.join('') + '/?' +
|
|
|
query.join('') + '#' + fragmentString + '&' + trail.join('')
|
|
query.join('') + '#' + fragmentString + '&' + trail.join('')
|
|
|
}),
|
|
}),
|
|
|
- result = $.PrivateBin.Modal.getPasteKey();
|
|
|
|
|
|
|
+ result = $.PrivateBin.Model.getPasteKey();
|
|
|
|
|
+ $.PrivateBin.Model.reset();
|
|
|
clean();
|
|
clean();
|
|
|
return fragmentString === result;
|
|
return fragmentString === result;
|
|
|
}
|
|
}
|
|
|
);
|
|
);
|
|
|
});
|
|
});
|
|
|
-
|
|
|
|
|
- describe('htmlEntities', function () {
|
|
|
|
|
- after(function () {
|
|
|
|
|
- cleanup();
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- jsc.property(
|
|
|
|
|
- 'removes all HTML entities from any given string',
|
|
|
|
|
- 'string',
|
|
|
|
|
- function (string) {
|
|
|
|
|
- var result = $.PrivateBin.Helper.htmlEntities(string);
|
|
|
|
|
- return !(/[<>"'`=\/]/.test(result)) && !(string.indexOf('&') > -1 && !(/&/.test(result)));
|
|
|
|
|
- }
|
|
|
|
|
- );
|
|
|
|
|
- });
|
|
|
|
|
});
|
|
});
|