0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-06 03:32:40 +00:00

Updated rendering to follow input line breaks

Updated and additional tests.
This commit is contained in:
David Bolack
2024-01-14 13:30:52 -06:00
parent d076d6c719
commit 4c2211c428
2 changed files with 15 additions and 11 deletions

View File

@@ -6,25 +6,24 @@ describe('Dictionary Terms', ()=>{
test('Single Definition', function() {
const source = 'My term :: My First Definition\n\n';
const rendered = Markdown.render(source);
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<dl><dt>My term</dt>\n<dd>My First Definition</dd>\n</dl>');
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<dl><dt>My term</dt><dd>My First Definition</dd>\n</dl>');
});
test('Two Definitions', function() {
const source = 'My term :: My First Definition :: My Second Definition\n\n';
const rendered = Markdown.render(source);
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<dl><dt>My term</dt>\n<dd>My First Definition</dd>\n<dd>My Second Definition</dd>\n</dl>');
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<dl><dt>My term</dt><dd>My First Definition</dd><dd>My Second Definition</dd>\n</dl>');
});
test('Three Definitions', function() {
const source = 'My term :: My First Definition :: My Second Definition :: My Third Definition\n\n';
const rendered = Markdown.render(source);
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<dl><dt>My term</dt>\n<dd>My First Definition</dd>\n<dd>My Second Definition</dd>\n<dd>My Third Definition</dd>\n</dl>');
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<dl><dt>My term</dt><dd>My First Definition</dd><dd>My Second Definition</dd><dd>My Third Definition</dd>\n</dl>');
});
test('Multiline Definitions', function() {
const source = '**Example** :: V3 uses HTML *definition lists* to create "lists" with hanging indents.\n::Three\n::Four\n\nHello::I\'m a different\n::List\n\n';
test('Multiple Definition Terms, multiple mixed-line definitions', function() {
const source = 'Term 1::Definition 1 of Term 1\n::Definition 2 of Term 1::Definition 3 of Term 1\nTerm 2::Definition of Term 2';
const rendered = Markdown.render(source);
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<dl><dt><strong>Example</strong></dt>\n<dd>V3 uses HTML <em>definition lists</em> to create “lists” with hanging indents.</dd>\n<dd>Three</dd>\n<dd>Four</dd>\n</dl><dl><dt>Hello</dt>\n<dd>I\m a different</dd>\n<dd>List</dd>\n</dl>');
});
});