added tests for getFormatterDefault(), fixing bug in compact design

This commit is contained in:
El RIDO 2017-05-26 20:55:45 +02:00
parent a30b31b315
commit fcfb02c2b7
No known key found for this signature in database
GPG key ID: 0F5C940A6BD81F92
2 changed files with 45 additions and 0 deletions

View file

@ -595,6 +595,40 @@ describe('Model', function () {
);
});
describe('getFormatDefault', function () {
before(function () {
$.PrivateBin.Model.reset();
cleanup();
});
jsc.property(
'returns the contents of the element with id "pasteFormatter"',
'array asciinestring',
'string',
'small nat',
function (keys, value, key) {
keys = keys.map($.PrivateBin.Helper.htmlEntities);
value = $.PrivateBin.Helper.htmlEntities(value);
var content = keys.length > key ? keys[key] : (keys.length > 0 ? keys[0] : 'null'),
contents = '<select id="pasteFormatter" name="pasteFormatter">';
keys.forEach(function(item) {
contents += '<option value="' + item + '"';
if (item === content) {
contents += ' selected="selected"';
}
contents += '>' + value + '</option>';
});
contents += '</select>';
$('body').html(contents);
var result = $.PrivateBin.Helper.htmlEntities(
$.PrivateBin.Model.getFormatDefault()
);
$.PrivateBin.Model.reset();
return content === result;
}
);
});
describe('getPasteId', function () {
before(function () {
$.PrivateBin.Model.reset();