Skip to content

Commit 5b23111

Browse files
committed
fix(mermaid): added tests
1 parent 0f3505c commit 5b23111

2 files changed

Lines changed: 60 additions & 0 deletions

File tree

‎tests/mermaid-preprocess.test.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = {};

‎tests/mermaid-preprocess.test.mjs‎

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import assert from 'node:assert/strict';
2+
import { createRequire } from 'node:module';
3+
4+
const require = createRequire(import.meta.url);
5+
const { doubleWrap } = require('../temp/temp.js');
6+
7+
const input = `
8+
flowchart TD
9+
Functioncall -->|GetMoney(Number amount) and| B(Go shopping)
10+
Functioncall -->|"Already quoted"| B("Already quoted")
11+
Functioncall -->|"Already quoted"| B("Function(string s) quoted")
12+
Functioncall -->|"Already quoted"| B{"Function{string s} quoted"}
13+
Functioncall -->|"Already quoted"| B["Function[string s] quoted"]
14+
Functioncall -->|"Already quoted"| B(Function(string s) quoted)
15+
Functioncall -->|"Already quoted"| B{Function{string s} quoted}
16+
Functioncall -->|"Already quoted"| B[Function[string s] quoted]
17+
A("Test") -->|"Already quoted"| B("Function(string s) quoted")
18+
A("Test") -->|"Already quoted"| B{"Function{string s} quoted"}
19+
A("Test") -->|"Already quoted"| B["Function[string s] quoted"]
20+
A(Test) -->|"Already quoted"| B(Function(string s) quoted)
21+
A(Test) -->|"Already quoted"| B{Function{string s} quoted}
22+
A(Test) -->|"Already quoted"| B[Function[string s] quoted]
23+
B --> C{Thinking(Number time)}
24+
C -->|"One"| D[La"ptop]
25+
C -->|Two| E["iPhone"]
26+
C -->|Three| F[fa:fa-car Car]
27+
`;
28+
29+
const expected = `
30+
flowchart TD
31+
Functioncall -->|"GetMoney(Number amount) and"| B("Go shopping")
32+
Functioncall -->|"Already quoted"| B("Already quoted")
33+
Functioncall -->|"Already quoted"| B("Function(string s) quoted")
34+
Functioncall -->|"Already quoted"| B{"Function{string s} quoted"}
35+
Functioncall -->|"Already quoted"| B["Function[string s] quoted"]
36+
Functioncall -->|"Already quoted"| B("Function(string s) quoted")
37+
Functioncall -->|"Already quoted"| B{"Function{string s} quoted"}
38+
Functioncall -->|"Already quoted"| B["Function[string s] quoted"]
39+
A("Test") -->|"Already quoted"| B("Function(string s) quoted")
40+
A("Test") -->|"Already quoted"| B{"Function{string s} quoted"}
41+
A("Test") -->|"Already quoted"| B["Function[string s] quoted"]
42+
A("Test") -->|"Already quoted"| B("Function(string s) quoted")
43+
A("Test") -->|"Already quoted"| B{"Function{string s} quoted"}
44+
A("Test") -->|"Already quoted"| B["Function[string s] quoted"]
45+
B --> C{"Thinking(Number time)"}
46+
C -->|"One"| D[La"ptop]
47+
C -->|"Two"| E["iPhone"]
48+
C -->|"Three"| F["fa:fa-car Car"]
49+
`;
50+
51+
try {
52+
const actual = doubleWrap(input);
53+
assert.equal(actual, expected);
54+
process.stdout.write('mermaid-preprocess: ok\n');
55+
} catch (err) {
56+
process.stderr.write('mermaid-preprocess: failed\n');
57+
process.stderr.write(String(err) + '\n');
58+
process.exitCode = 1;
59+
}

0 commit comments

Comments
 (0)