Skip to content

Commit 33a231f

Browse files
committed
tests - Add some simple intermediate markdown snapshot test cases
This way we check that a basic markdown intermediate is as expected, and with no unprocessed cell div :::
1 parent 307cdf6 commit 33a231f

File tree

7 files changed

+135
-0
lines changed

7 files changed

+135
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
title: "Untitled"
3+
format: markdown
4+
keep-md: true
5+
engine: julia
6+
---
7+
8+
This does it:
9+
10+
::: {.cell execution_count=1}
11+
``` {.julia .cell-code}
12+
1 + 1
13+
```
14+
15+
::: {.cell-output .cell-output-display execution_count=1}
16+
```
17+
2
18+
```
19+
:::
20+
:::
21+
22+
23+
Other content
24+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: "Untitled"
3+
format: markdown
4+
keep-md: true
5+
engine: julia
6+
---
7+
8+
This does it:
9+
```{julia}
10+
1 + 1
11+
```
12+
Other content
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
title: "Untitled"
3+
format: markdown
4+
keep-md: true
5+
---
6+
7+
This does it:
8+
9+
::: {.cell execution_count=1}
10+
``` {.python .cell-code}
11+
1 + 1
12+
```
13+
14+
::: {.cell-output .cell-output-display execution_count=1}
15+
```
16+
2
17+
```
18+
:::
19+
:::
20+
21+
22+
Other content
23+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title: "Untitled"
3+
format: markdown
4+
keep-md: true
5+
---
6+
7+
This does it:
8+
```{python}
9+
1 + 1
10+
```
11+
Other content
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
title: "Untitled"
3+
format: markdown
4+
keep-md: true
5+
---
6+
7+
This does it:
8+
9+
::: {.cell}
10+
11+
```{.r .cell-code}
12+
1 + 1
13+
```
14+
15+
::: {.cell-output .cell-output-stdout}
16+
17+
```
18+
[1] 2
19+
```
20+
21+
22+
:::
23+
:::
24+
25+
Other content
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title: "Untitled"
3+
format: markdown
4+
keep-md: true
5+
---
6+
7+
This does it:
8+
```{r}
9+
1 + 1
10+
```
11+
Other content
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { dirname, join } from "path";
2+
import { ensureSnapshotMatches, noErrors, printsMessage } from "../../verify.ts";
3+
import { fileLoader } from "../../utils.ts";
4+
import { safeRemoveIfExists } from "../../../src/core/path.ts";
5+
import { testRender } from "../render/render.ts";
6+
7+
// Define engines to test
8+
const engines = [
9+
{ name: "knitr" },
10+
{ name: "jupyter" },
11+
{ name: "julia" }
12+
];
13+
14+
// Run tests for each engine
15+
engines.forEach(engine => {
16+
// Test for engine
17+
const inputQmd = fileLoader(engine.name, "intermediate-markdown-output")("output-cell-div.qmd", "markdown");
18+
const md = join(dirname(inputQmd.input), "output-cell-div.markdown.md");
19+
testRender(inputQmd.input, "markdown", true, [
20+
noErrors,
21+
// Lua Warning are in INFO
22+
printsMessage({ level: "INFO", regex: /WARNING \(.*\)\s+The following string was found in the document: :::/, negate: true}),
23+
ensureSnapshotMatches(md)
24+
], {
25+
teardown: async () => {
26+
safeRemoveIfExists(md);
27+
} });
28+
});
29+

0 commit comments

Comments
 (0)