Skip to content

Commit

Permalink
Add test for issue #58
Browse files Browse the repository at this point in the history
  • Loading branch information
alexprey committed Feb 12, 2021
1 parent 9609d5a commit 46323c4
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/unit/helpers/helpers.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,47 @@ let variable = 2;
expect(block.content).is.eq('\nlet variable = 2;\n');
expect(block.attributes).is.empty;
});

// TODO Re-enable for following issue: https://github.com/alexprey/sveltedoc-parser/issues/58
xit('When html block contains complex markup with escaping and string usages should provide a correct result', () => {
const content = `
<script>
export let items = [];
</script>
<Panel title="Basic tabs" shadow={true}>
<Tabs bind:items={items}/>
<br><br>
<strong>Active tab:</strong> {activeTab1[0].title}
<br>
<br>
<Code>
{@html highlight(
'<script> \n' +
' const items = [ \n' +
' { title: "Tab 1", active: true }, \n' +
' { title: "Tab 2", active: false }, \n' +
' { title: "Tab 3", active: false }, \n' +
' { title: "Tab 4", active: false }, \n' +
' ]; \n' +
'</script> \n\n' +
'<Tabs bind:items={items} />')}
</Code>
</Panel>
`;

const result = helpers.extractAllHtmlBlocks(content, 'script');

expect(result).is.exist;
expect(result.blocks).is.exist;
expect(result.blocks.length).is.eq(1);

const block = result.blocks[0];

expect(block).is.exist;
expect(block.offset).is.eq(9);
expect(block.content).is.eq('\nexport let items = [];\n');
expect(block.attributes).is.empty;
});
});
});

0 comments on commit 46323c4

Please sign in to comment.