-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
svg_test.ts
43 lines (38 loc) · 962 Bytes
/
svg_test.ts
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
import { assertEquals } from "@std/assert";
import { Svg } from "./svg.ts";
Deno.test("error", async () => {
const resultSvg = await Deno.readTextFile(
"./resources/tests/test_error.svg",
);
const msg = "this is an error message!";
assertEquals(
Svg.error(msg),
resultSvg.trim().replace("ERROR_MESSAGE", msg),
);
});
Deno.test("success", async () => {
const resultSvg = await Deno.readTextFile(
"./resources/tests/test_render.svg",
);
// replace l0-l4 to 'level' to avoid random output
const levels = /l[1-4]/g;
const text = "This is text ";
const colors = [
"#000000",
"#00ff00",
"#0000ff",
"#ffff00",
"#00ffff",
];
const bg = "#ff0000";
const frame = "#ff00ff";
// const speed = 200;
const comment = "super comment";
assertEquals(
Svg.render({ text, colors, bg, frame, comment }).replace(
levels,
"level",
),
resultSvg.trim().replace(levels, "level"),
);
});