function cleanTest (test) { var code = test.fn ? test.fn.toString() : test.body, err = test.err ? _.pick( test.err, ['name', 'message', 'stack'] ) : test.err; if (code) { code = cleanCode(code); code = Highlight.fixMarkup(Highlight.highlightAuto(code).value); } if (err && err.stack) { err.stack = Highlight.fixMarkup(Highlight.highlightAuto(err.stack).value); } var cleaned = { title: test.title, fullTitle: test.fullTitle(), timedOut: test.timedOut, duration: test.duration || 0, state: test.state, speed: test.speed, pass: test.state === 'passed', fail: test.state === 'failed', pending: test.pending, code: code, err: err, isRoot: test.parent.root, uuid: uuid.v4(), parentUUID: test.parent.uuid }; cleaned.skipped = (!cleaned.pass && !cleaned.fail && !cleaned.pending); return cleaned; }
/** * Clean a test or hook to only return information we're interested in. * @param {Test|Hook} test data to work against * @returns {*} cleaned test. */ function cleanTest (test) { if (!test.uuid) { test.uuid = uuid.v4(); } var code = ''; var err = test.err ? _.pick(test.err, ['name', 'message', 'stack']) : null; if (test.fn) { code = beautify(test.fn.toString(), {'indent_size': 2}); code = Highlight.highlightAuto(code).value; code = Highlight.fixMarkup(code); } if (err && err.stack) { err.stack = Highlight.fixMarkup(Highlight.highlightAuto(err.stack).value); } var cleaned = { 'uuid': test.uuid, 'title': test.title, 'fullTitle': test.fullTitle(), 'timedOut': test.timedOut, 'duration': test.duration || 0, 'state': test.state, 'speed': test.speed, 'pass': test.state === 'passed', 'fail': test.state === 'failed', 'pending': test.pending, 'code': code, 'err': err, 'isRoot': test.parent.root, 'parent': cleanSuite(test.parent) }; cleaned.skipped = !cleaned.pass && !cleaned.fail && !cleaned.pending; return cleaned; }
'swagger--example': function (example, mimeType, options, customize) { if (_.isObject(example)) { switch (mimeType) { case 'application/json': example = require('json-stable-stringify')(example, {space: 4}) break case 'application/xml': // TODO: This should actually convert the example to XML but I don't know how yet. "help wanted" example = require('json-stable-stringify')(example, {space: 4}) break } } var highlighted = highlight.highlightAuto(String(example)).value var fixMarkup = highlight.fixMarkup(highlighted) return new customize.engine.SafeString('<pre>' + fixMarkup + '</pre>') }
/** * Return a plain-object representation of `test` * free of cyclic properties etc. * * @param {Object} test * @return {Object} * @api private */ function CleanTest(test) { let err = test.err ? _.pick(test.err, ['name', 'message', 'stack']) : test.err if (err && err.stack) { err.stack = Highlight.fixMarkup(Highlight.highlightAuto(err.stack).value) } let cleaned = { title: test.title, fullTitle: test.fullTitle(), timedOut: test.timedOut, duration: test.duration || 0, speed: test.speed, //pass: test.state === 'passed', //fail: test.state === 'failed', //pending: test.pending, err: err, isRoot: test.parent.root, //uuid: uuid.v4(), //parentUUID: test.parent.uuid } if (test.state === 'passed') { cleaned.state = PASS } else if (test.state === 'failed') { cleaned.state = FAIL } else { cleaned.state = SKIP } //cleaned.skipped = (!cleaned.pass && !cleaned.fail && !cleaned.pending) return cleaned }
Array.prototype.slice.apply(doc.getElementsByTagName('code')).forEach(function(code) { code.innerHTML = hljs.fixMarkup(hljs.highlightAuto(entities.decodeHTML(code.innerHTML)).value); });