/* eslint-disable max-lines */ const dedent = require('dedent-tabs').default; const Markdown = require('naturalcrit/markdown.js'); // Marked.js adds line returns after closing tags on some default tokens. // This removes those line returns for comparison sake. String.prototype.trimReturns = function(){ return this.replace(/\r?\n|\r/g, '').trim(); }; // Adding `.failing()` method to `describe` or `it` will make failing tests "pass" as long as they continue to fail. // Remove the `.failing()` method once you have fixed the issue. describe('Block-level variables', ()=>{ it('Handles variable assignment and recall with simple text', function() { const source = dedent` [var]: string $[var] `; const rendered = Markdown.render(source).trimReturns(); expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('
string
'); }); it('Handles variable assignment and recall with multiline string', function() { const source = dedent` [var]: string across multiple lines $[var]`; const rendered = Markdown.render(source).replace(/\s/g,' ').trimReturns(); expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('string across multiple lines
'); }); it('Handles variable assignment and recall with tables', function() { const source = dedent` [var]: ##### Title | H1 | H2 | |:---|:--:| | A | B | | C | D | $[var]`; const rendered = Markdown.render(source).replace(/\s/g,' ').trimReturns(); expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(dedent`| H1 | H2 |
|---|---|
| A | B |
| C | D |