-
Notifications
You must be signed in to change notification settings - Fork 5
/
teacher.test.js
53 lines (48 loc) · 1.33 KB
/
teacher.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
import * as fs from "fs";
import * as path from "path";
import React from "react";
import { act, render, fireEvent, screen } from "@testing-library/react";
import { Context as TestContext } from "../../test/app_context";
import Teacher from "./teacher";
const mountFile = (node, data = "") => {
const file = new File([data], "chucknorris.png", { type: "image/png" });
fireEvent.change(node, { target: { files: [file] } });
};
const getTestCsv = (name) => {
const rootDir = path.join(
__dirname,
"..",
"..",
"..",
"..",
"..",
"ui_testing_data"
);
return fs
.readFileSync(path.join(rootDir, name), { encoding: "utf8" })
.toString();
return result;
};
describe("teacher", () => {
// Integration test of the full gallery creation flow
it("is possible to make a gallery", async () => {
render(
<TestContext initialState={{ auth: { isAuthenticated: true } }}>
<Teacher />
</TestContext>
);
// Upload file
act(() => {
mountFile(
screen.getByTestId("csvFileInput"),
getTestCsv("test_group.csv")
);
fireEvent.click(screen, "addSpreadsheetButton");
fireEvent.click(screen, "verifyGroupButton");
});
expect(screen.getByTestId("firstFileUploadedMsg")).toHaveTextContent(
"🎉Nice!🎊"
);
// Click "Add Group"
});
});