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 = '' + '' + '' + '' + '' + '' + '
ABC
3412
'; 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 = '' + '' + '' + '' + '' + '' + '
ABC
34A*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 PriceQtySubtotal
$1.232$2.46
$4.996$29.94
Total$32.40
'; const actual = this.md(markdown); this.assertEqual(expected, actual); } test_styledValue() { const markdown = "| A | B | C |\n| --- | --- | --- |\n| **3** | _4_ | =A*B |"; const expected = '' + '' + '' + '' + '' + '' + '
ABC
3412
'; const actual = this.md(markdown); this.assertEqual(expected, actual); } test_styledFormula() { const markdown = "| A | B | C |\n| --- | --- | --- |\n| 3 | 4 | **=A*B** |"; const expected = '' + '' + '' + '' + '' + '' + '
ABC
3412
'; const actual = this.md(markdown); this.assertEqual(expected, actual); } test_styledFormula_multiple() { const markdown = "| A | B | C |\n| --- | --- | --- |\n| 3 | 4 | ~~**=A*B**~~ |"; const expected = '' + '' + '' + '' + '' + '' + '
ABC
3412
'; const actual = this.md(markdown); this.assertEqual(expected, actual); } test_preservedOperators() { // Regular markdown will want to convert *B* into emphasized B const markdown = "| A | B | C |\n| --- | --- | --- |\n| 3 | 4 | =A*B*4 |"; const expected = '' + '' + '' + '' + '' + '' + '
ABC
3448
'; const actual = this.md(markdown); this.assertEqual(expected, actual); } }