mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2024-03-22 13:10:41 +08:00
added test for selectText function, but discovered that this can't be tested at the moment without a browser, due to jsdom lacking getSelect support
This commit is contained in:
parent
0091607618
commit
3ab489e92d
27
js/test.js
27
js/test.js
|
@ -66,6 +66,33 @@ describe('helper', function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// this test is not yet meaningful using jsdom, as it does not contain getSelection support.
|
||||||
|
// TODO: This needs to be tested using a browser.
|
||||||
|
describe('selectText', function () {
|
||||||
|
jsc.property(
|
||||||
|
'selection contains content of given ID',
|
||||||
|
'nearray string',
|
||||||
|
'nearray nestring',
|
||||||
|
function (ids, contents) {
|
||||||
|
//console.log(ids, contents);
|
||||||
|
var html = '',
|
||||||
|
result = true;
|
||||||
|
ids.forEach(function(item, i) {
|
||||||
|
html += '<div id="' + item + '">' + (contents[i] || contents[0]) + '</div>';
|
||||||
|
});
|
||||||
|
var clean = jsdom(html);
|
||||||
|
ids.forEach(function(item, i) {
|
||||||
|
$.PrivateBin.helper.selectText(item);
|
||||||
|
// TODO: As per https://github.com/tmpvar/jsdom/issues/321 there is no getSelection in jsdom, yet.
|
||||||
|
// Once there is one, uncomment the line below to actually check the result.
|
||||||
|
//result *= (contents[i] || contents[0]) === window.getSelection().toString();
|
||||||
|
});
|
||||||
|
clean();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
describe('scriptLocation', function () {
|
describe('scriptLocation', function () {
|
||||||
jsc.property(
|
jsc.property(
|
||||||
'returns the URL without query & fragment',
|
'returns the URL without query & fragment',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user