diff --git a/js/privatebin.js b/js/privatebin.js index a512283b..63087a54 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -1839,7 +1839,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) { * * @name PasteViewer.setFormat * @function - * @param {string} newFormat the the new format + * @param {string} newFormat the new format */ me.setFormat = function(newFormat) { @@ -1848,7 +1848,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) { return; } - // needs to update display too, if from or to Markdown is switched + // needs to update display too, if we switch from or to Markdown if (format === 'markdown' || newFormat === 'markdown') { isDisplayed = false; } @@ -1977,6 +1977,9 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) { // get default option from template/HTML or fall back to set value format = Model.getFormatDefault() || format; + text = ''; + isDisplayed = false; + isChanged = true; } return me; diff --git a/js/test.js b/js/test.js index 23238469..8f815672 100644 --- a/js/test.js +++ b/js/test.js @@ -22,6 +22,10 @@ global.sjcl = require('./sjcl-1.0.6'); global.Base64 = require('./base64-2.1.9').Base64; global.RawDeflate = require('./rawdeflate-0.5').RawDeflate; global.RawDeflate.inflate = require('./rawinflate-0.3').RawDeflate.inflate; +require('./prettify'); +global.prettyPrint = window.PR.prettyPrint; +global.prettyPrintOne = window.PR.prettyPrintOne; +global.showdown = require('./showdown-1.6.1'); require('./bootstrap-3.3.7'); require('./privatebin'); @@ -1374,3 +1378,70 @@ describe('Editor', function () { }); }); +describe('PasteViewer', function () { + describe('run, hide, getText, setText, getFormat, setFormat & isPrettyPrinted', function () { + this.timeout(30000); + before(function () { + cleanup(); + }); + + jsc.property( + 'displays text according to format', + jsc.elements(['plaintext', 'markdown', 'syntaxhighlighting']), + 'nestring', + function (format, text) { + var clean = jsdom(), + results = []; + $('body').html( + '