-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathChart.test.tsx
41 lines (37 loc) · 1.32 KB
/
Chart.test.tsx
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
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { assertStringIncludes } from "std/assert/mod.ts";
import { render } from "preact-render-to-string";
import { Chart } from "./Chart.tsx";
Deno.test({
name: "Chart - renders",
fn() {
const actual = render(<Chart data={{ datasets: [] }} />);
assertStringIncludes(
actual,
`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="768px" height="384px" viewBox="0 0 768 384">`,
);
},
});
Deno.test({
name: "Chart - renders with svgClass, svgStyle",
fn() {
let actual = render(
<Chart
data={{ datasets: [] }}
svgClass="w-full"
svgStyle="width: 100%;"
/>,
);
assertStringIncludes(
actual,
`<svg class="w-full" style="width: 100%;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="768px" height="384px" viewBox="0 0 768 384">`,
);
actual = render(
<Chart data={{ datasets: [] }} svgClass={`"`} svgStyle={`"`} />,
);
assertStringIncludes(
actual,
`<svg class=""" style=""" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="768px" height="384px" viewBox="0 0 768 384">`,
);
},
});