-
Notifications
You must be signed in to change notification settings - Fork 12
/
testing.tsx
87 lines (71 loc) · 1.87 KB
/
testing.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import QUnit from "qunit"
import React, { useEffect } from "react"
import { Helmet } from "react-helmet"
import d3Tests from "@/tests/qunit/d3"
import raphaelTests from "@/tests/qunit/raphael"
import threeJSTests from "@/tests/qunit/threeJS"
const setupTitle = () => {
const implementationsLink = document.createElement("a")
const divisor = document.createElement("span")
implementationsLink.setAttribute(
"href",
"https://github.com/igncp/demos/tree/main/src/tests/qunit"
)
implementationsLink.setAttribute("target", "_blank")
implementationsLink.innerText = "Read tests files in Github"
divisor.innerText = " | "
const header = document.querySelector("#qunit-header")
const anchor = header?.querySelector("a")
if (anchor) {
anchor.setAttribute("href", ROOT_PATH)
anchor.innerText = "Demos"
}
header?.appendChild(divisor)
header?.appendChild(implementationsLink)
}
const Testing = () => {
useEffect(() => {
if (typeof window === "undefined") {
return () => {}
}
QUnit.module("d3", () => {
d3Tests(QUnit)
})
QUnit.module("raphael", () => {
raphaelTests(QUnit)
})
QUnit.module("threeJS", () => {
threeJSTests(QUnit)
})
QUnit.start()
let timeoutId: number | null = window.setTimeout(() => {
timeoutId = null
setupTitle()
}, 20)
return () => {
if (timeoutId) {
clearTimeout(timeoutId)
}
}
}, [])
return (
<div>
<Helmet
meta={[
{
content: "Testing page for learning the usage of libraries like D3",
name: "description",
},
]}
title={"Demos - QUnit Tests"}
/>
<link
href="https://code.jquery.com/qunit/qunit-2.16.0.css"
rel="stylesheet"
/>
<div id="qunit" />
<div id="qunit-fixture" />
</div>
)
}
export default Testing