-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.test.js
57 lines (47 loc) · 1.36 KB
/
main.test.js
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
import { screen } from "@testing-library/dom";
import userEvent from "@testing-library/user-event";
import m from "mithril";
import myapp from "./public/myapp";
const { exports_for_js } = myapp;
const {
mountApp,
fact,
getBoolFromJs,
maxViaJsInline,
runAllTestsJest,
} = exports_for_js();
test("run all mini-fiveam tests", () => {
const [result, report] = runAllTestsJest();
console.log(report);
expect(result).toBe(true);
});
test("uses jest-dom", async () => {
const user = userEvent.setup();
window.document.body.innerHTML = '<div id="app"></div>';
mountApp();
expect(
screen.getByRole("heading", { name: "Othello Square" })
).toBeInTheDocument();
const nicknameInput = document.getElementById("nickname");
await user.type(nicknameInput, "Peter");
screen.getByRole("button", { name: "Login" }).click();
m.redraw.sync();
// expect(
// screen.getByTestId("message", { name: "Welcome, Peter!" })
// ).toBeInTheDocument();
});
test("fact", () => {
expect(fact(5)).toBe(120);
expect(fact(6)).toBe(720);
expect(fact(7)).toBe(5040);
expect(fact(8)).toBe(40320);
});
test("getBoolFromJs", () => {
expect(getBoolFromJs(1)).toBe(1);
expect(getBoolFromJs(2)).toBe(2);
});
test("maxViaJsInline", () => {
expect(maxViaJsInline(1, 2)).toBe(2);
expect(maxViaJsInline(1, 1)).toBe(1);
expect(maxViaJsInline(200, 100)).toBe(200);
});