2017-12-15 06:20:51 +00:00
|
|
|
'use strict';
|
2018-01-06 12:32:07 +00:00
|
|
|
require('../common');
|
2017-12-15 06:20:51 +00:00
|
|
|
|
|
|
|
describe('Editor', function () {
|
|
|
|
describe('show, hide, getText, setText & isPreview', function () {
|
|
|
|
this.timeout(30000);
|
|
|
|
|
|
|
|
jsc.property(
|
|
|
|
'returns text fed into the textarea, handles editor tabs',
|
|
|
|
'string',
|
|
|
|
function (text) {
|
|
|
|
var clean = jsdom(),
|
|
|
|
results = [];
|
|
|
|
$('body').html(
|
|
|
|
'<ul id="editorTabs" class="nav nav-tabs hidden"><li ' +
|
|
|
|
'role="presentation" class="active"><a id="messageedit" ' +
|
|
|
|
'href="#">Editor</a></li><li role="presentation"><a ' +
|
|
|
|
'id="messagepreview" href="#">Preview</a></li></ul><div ' +
|
|
|
|
'id="placeholder" class="hidden">+++ no paste text +++</div>' +
|
|
|
|
'<div id="prettymessage" class="hidden"><pre id="prettyprint" ' +
|
|
|
|
'class="prettyprint linenums:1"></pre></div><div ' +
|
|
|
|
'id="plaintext" class="hidden"></div><p><textarea ' +
|
|
|
|
'id="message" name="message" cols="80" rows="25" ' +
|
|
|
|
'class="form-control hidden"></textarea></p>'
|
|
|
|
);
|
|
|
|
$.PrivateBin.Editor.init();
|
|
|
|
results.push(
|
|
|
|
$('#editorTabs').hasClass('hidden') &&
|
|
|
|
$('#message').hasClass('hidden')
|
|
|
|
);
|
|
|
|
$.PrivateBin.Editor.show();
|
|
|
|
results.push(
|
|
|
|
!$('#editorTabs').hasClass('hidden') &&
|
|
|
|
!$('#message').hasClass('hidden')
|
|
|
|
);
|
|
|
|
$.PrivateBin.Editor.hide();
|
|
|
|
results.push(
|
|
|
|
$('#editorTabs').hasClass('hidden') &&
|
|
|
|
$('#message').hasClass('hidden')
|
|
|
|
);
|
|
|
|
$.PrivateBin.Editor.show();
|
|
|
|
$.PrivateBin.Editor.focusInput();
|
|
|
|
results.push(
|
2018-01-06 06:17:33 +00:00
|
|
|
$.PrivateBin.Editor.getText().length === 0
|
2017-12-15 06:20:51 +00:00
|
|
|
);
|
|
|
|
$.PrivateBin.Editor.setText(text);
|
|
|
|
results.push(
|
2018-01-06 06:17:33 +00:00
|
|
|
$.PrivateBin.Editor.getText() === $('#message').val()
|
2017-12-15 06:20:51 +00:00
|
|
|
);
|
|
|
|
$.PrivateBin.Editor.setText();
|
|
|
|
results.push(
|
|
|
|
!$.PrivateBin.Editor.isPreview() &&
|
|
|
|
!$('#message').hasClass('hidden')
|
|
|
|
);
|
2022-02-20 20:07:04 +00:00
|
|
|
$('#messagepreview').trigger('click');
|
2017-12-15 06:20:51 +00:00
|
|
|
results.push(
|
|
|
|
$.PrivateBin.Editor.isPreview() &&
|
|
|
|
$('#message').hasClass('hidden')
|
|
|
|
);
|
2022-02-20 20:07:04 +00:00
|
|
|
$('#messageedit').trigger('click');
|
2017-12-15 06:20:51 +00:00
|
|
|
results.push(
|
|
|
|
!$.PrivateBin.Editor.isPreview() &&
|
|
|
|
!$('#message').hasClass('hidden')
|
|
|
|
);
|
|
|
|
clean();
|
|
|
|
return results.every(element => element);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|