-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.ts
44 lines (35 loc) · 1.44 KB
/
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
44
import { getSVGRenderer } from "./mod.ts";
import { assertStringIncludes } from "https://deno.land/[email protected]/testing/asserts.ts";
Deno.test("SVG renderer should generate SVG with correct style attributes", async () => {
const r = await getSVGRenderer({
fontFamily: "IBM Plex Mono",
});
const out = r.renderToSVG([[{ content: "foo", color: "#aabbccff" }]]);
// 0x40 = 64, 0xff = 256. 64/256 = 0.25
assertStringIncludes(out, 'opacity="1"');
assertStringIncludes(out, 'font-family="IBM Plex Mono"');
});
Deno.test("SVG can have 0 corner radius", async () => {
const r = await getSVGRenderer({
fontFamily: "IBM Plex Mono",
bgCornerRadius: 0,
});
const out = r.renderToSVG([[{ content: "foo", color: "#aabbccff" }]]);
assertStringIncludes(out, 'rx="0"');
});
Deno.test(`SVG renderer should default to minimal background width correctly`, async () => {
const r = await getSVGRenderer({
fontFamily: "IBM Plex Mono",
bgMinWidth: 180,
});
const out = r.renderToSVG([[{ content: "foo", color: "#aabbccff" }]]);
assertStringIncludes(out, `<svg viewBox="0 0 180 `);
});
Deno.test(`SVG renderer should ignore minimal background width when it's own boundaries are above that`, async () => {
const r = await getSVGRenderer({
fontFamily: "IBM Plex Mono",
bgMinWidth: 150,
});
const out = r.renderToSVG([[{ content: "foo", color: "#aabbccff" }]]);
assertStringIncludes(out, `<svg viewBox="0 0 156.4921875 `);
});