'use strict'; require('../common'); const fc = require('fast-check'); describe('Editor', function () { describe('show, hide, getText, setText & isPreview', function () { this.timeout(30000); it('returns text fed into the textarea, handles editor tabs', () => { fc.assert(fc.property( fc.string(), function (text) { var clean = globalThis.cleanup(), results = []; document.body.innerHTML = ( '' + '' + '' + '' + '

' + '' + '

' + '' ); PrivateBin.Editor.init(); results.push( document.getElementById('editorTabs').classList.contains('hidden') && document.getElementById('message').classList.contains('hidden') ); PrivateBin.Editor.show(); results.push( !document.getElementById('editorTabs').classList.contains('hidden') && !document.getElementById('message').classList.contains('hidden') ); PrivateBin.Editor.hide(); results.push( document.getElementById('editorTabs').classList.contains('hidden') && document.getElementById('message').classList.contains('hidden') ); PrivateBin.Editor.show(); PrivateBin.Editor.focusInput(); results.push( PrivateBin.Editor.getText().length === 0 ); PrivateBin.Editor.setText(text); results.push( PrivateBin.Editor.getText() === document.getElementById('message').value ); PrivateBin.Editor.setText(); results.push( !PrivateBin.Editor.isPreview() && !document.getElementById('message').classList.contains('hidden') ); document.getElementById('messagepreview').click(); results.push( PrivateBin.Editor.isPreview() && document.getElementById('message').classList.contains('hidden') ); document.getElementById('messageedit').click(); results.push( !PrivateBin.Editor.isPreview() && !document.getElementById('message').classList.contains('hidden') ); clean(); return results.every(element => element); } )); }); }); });