class SpreadsheetMarkdownIntegrationTests extends BaseTest {
parser;
setUp() {
this.parser = new Markdown([ ...Markdown.allReaders, new MDSpreadsheetReader() ]);
}
md(markdown) {
return normalizeWhitespace(this.parser.toHTML(markdown));
}
test_integration() {
const markdown = '| A | B | C |\n| --- | --- | --- |\n| 3 | 4 | =A*B |';
const expected = '
' +
'| A | B | C |
' +
'' +
'| 3 | ' +
'4 | ' +
'12 | ' +
'
';
const actual = this.md(markdown);
this.assertEqual(expected, actual);
}
test_bailOut() {
// If no formulas found table isn't modified
const markdown = '| A | B | C |\n| --- | --- | --- |\n| 3 | 4 | A*B |';
const expected = '' +
'| A | B | C |
' +
'' +
'| 3 | ' +
'4 | ' +
'A*B | ' +
'
';
const actual = this.md(markdown);
this.assertEqual(expected, actual);
}
test_observedError1() {
// Saw "Uncaught Error: columnIndex must be number, got string" from this
const markdown = '| Unit Price | Qty | Subtotal |\n| ---: | ---: | ---: |\n| $1.23 | 2 | =A*B FILL |\n| $4.99 | 6 | |\n| Total | | =SUM(C:C) |';
const expected = '' +
'| Unit Price | ' +
'Qty | ' +
'Subtotal | ' +
'
' +
'| $1.23 | ' +
'2 | ' +
'$2.46 | ' +
'
' +
'| $4.99 | ' +
'6 | ' +
'$29.94 | ' +
'
' +
'| Total | ' +
' | ' +
'$32.40 | ' +
'
';
const actual = this.md(markdown);
this.assertEqual(expected, actual);
}
}