-
Notifications
You must be signed in to change notification settings - Fork 250
/
run-tests.sh
executable file
·59 lines (47 loc) · 2.31 KB
/
run-tests.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh
INPUT_DATA=$1
IMAGETAG=$2
set -e
# we must set `useMaxWidth: false` in config` to convert-svg-to-png for Percy CI
config_noUseMaxWidth="$INPUT_DATA/config-noUseMaxWidth.json"
# Test if the CLI actually works (PNG)
for i in $(ls $INPUT_DATA/*.mmd); do docker run --rm -v $(pwd):/data $IMAGETAG -i /data/$i -o /data/$i.png -w 800; done
# Test if the CLI actually works (PNG) for md files
for i in $(ls $INPUT_DATA/*.md); do docker run --rm -v $(pwd):/data $IMAGETAG -i /data/$i -o /data/$i.png -w 800; done
# Test if the CLI actually works (PDF)
for i in $(ls $INPUT_DATA/*.mmd); do docker run --rm -v $(pwd):/data $IMAGETAG -i /data/$i -o /data/$i.pdf; done
# Test if passing background colors works
for format in "svg" "png"; do
# must have different names, since we convert .svg to .png for percy upload
outputFileName="/data/$INPUT_DATA/flowchart1-red-background-${format}.${format}"
docker run --rm -v $(pwd):/data $IMAGETAG \
-i /data/$INPUT_DATA/flowchart1.mmd \
--configFile "/data/$config_noUseMaxWidth" \
--backgroundColor "red" \
-o "$outputFileName"
done
# Test if passing CSS styles works
for format in "svg" "png"; do
# must have different names, since we convert .svg to .png for percy upload
outputFileName="/data/$INPUT_DATA/flowchart1-with-css-${format}.${format}"
docker run --rm -v $(pwd):/data $IMAGETAG \
-i /data/$INPUT_DATA/flowchart1.mmd \
--configFile "/data/$config_noUseMaxWidth" \
--cssFile /data/$INPUT_DATA/flowchart1.css \
-o "$outputFileName"
done
# Test if a diagram from STDIN can be understood
cat $INPUT_DATA/flowchart1.mmd | docker run --rm -i -v $(pwd):/data $IMAGETAG -o /data/$INPUT_DATA/flowchart1-stdin.png -w 800
# Test if mmdc crashes on Markdown files containing no mermaid charts
OUTPUT=$(docker run --rm -v $(pwd):/data $IMAGETAG -i /data/test-positive/no-charts.md)
EXPECTED_OUTPUT="No mermaid charts found in Markdown input"
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || echo "Expected output to be '$EXPECTED_OUTPUT', got '$OUTPUT'"
# Test if mmdc does not replace <br> with <br/>
docker run --rm -v $(pwd):/data $IMAGETAG \
-i /data/test-positive/graph-with-br.mmd \
--width 800 \
--configFile "/data/$config_noUseMaxWidth"
if grep -q "<br>" "./test-positive/graph-with-br.mmd.svg"; then
echo "<br> has not been replaced with <br/>";
exit 1;
fi