From e39e959347e041a6bf89bfb95d15428094dcee40 Mon Sep 17 00:00:00 2001 From: John McLear Date: Tue, 12 Jan 2021 20:21:55 +0000 Subject: [PATCH] basic test and hacked in stuff --- src/static/js/contentcollector.js | 9 ++++----- tests/backend/specs/contentcollector.js | 12 ++++++++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/static/js/contentcollector.js b/src/static/js/contentcollector.js index 7177732db..d3140ae20 100644 --- a/src/static/js/contentcollector.js +++ b/src/static/js/contentcollector.js @@ -76,6 +76,7 @@ function makeContentCollector(collectStyles, abrowser, apool, domInterface, clas p: 1, pre: 1, li: 1, + img: 1, }; _.each(hooks.callAll('ccRegisterBlockElements'), (element) => { @@ -421,12 +422,10 @@ function makeContentCollector(collectStyles, abrowser, apool, domInterface, clas cls, node, }); - } else { - // THIS SEEMS VERY HACKY! -- Please submit a better fix! - delete state.lineAttributes.img; - } + // cc.doAttrib(state, 'image:foo.png'); + state.lineAttributes.img = 'foo.png'; - if (tname == 'br') { + } else if (tname == 'br') { this.breakLine = true; const tvalue = dom.nodeAttr(node, 'value'); const induceLineBreak = hooks.callAll('collectContentLineBreak', { diff --git a/tests/backend/specs/contentcollector.js b/tests/backend/specs/contentcollector.js index c85904917..408ae4f0c 100644 --- a/tests/backend/specs/contentcollector.js +++ b/tests/backend/specs/contentcollector.js @@ -15,6 +15,13 @@ const AttributePool = require('../../../src/static/js/AttributePool'); const cheerio = require('../../../src/node_modules/cheerio'); const tests = { + image: { + description: 'Puts an image in the content', + html: '

image

', + expectedLineAttribs: ['+5', '*0*1*2+1'], + expectedText: ['image', '*'], + }, +/* nestedLi: { description: 'Complex nested Li', html: '
  1. one
    1. 1.1
  2. two
', @@ -271,6 +278,7 @@ pre expectedLineAttribs: ['+f*0+2+2'], expectedText: ['Need more space s !'] }, +*/ }; describe(__filename, function () { @@ -300,7 +308,7 @@ describe(__filename, function () { // Check recieved text matches the expected text if (arraysEqual(recievedText[0], expectedText)) { - // console.log("PASS: Recieved Text did match Expected Text\nRecieved:", recievedText[0], "\nExpected:", testObj.expectedText) + console.log("PASS: Recieved Text did match Expected Text\nRecieved:", recievedText[0], "\nExpected:", testObj.expectedText) } else { console.error('FAIL: Recieved Text did not match Expected Text\nRecieved:', recievedText[0], '\nExpected:', testObj.expectedText); throw new Error(); @@ -308,7 +316,7 @@ describe(__filename, function () { // Check recieved attributes matches the expected attributes if (arraysEqual(recievedAttributes, expectedAttributes)) { - // console.log("PASS: Recieved Attributes matched Expected Attributes"); + console.log("PASS: Recieved Attributes matched Expected Attributes", recievedAttributes, expectedAttributes); done(); } else { console.error('FAIL', test, testObj.description);