refactor: Rewrite to typescript
All checks were successful
Remote Deploy / deploy (push) Successful in 14s
All checks were successful
Remote Deploy / deploy (push) Successful in 14s
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
import fs from "fs";
|
||||
import parseAbsence from "../scrape/utils/parseAbsence.js";
|
||||
|
||||
const teachermap = JSON.parse(fs.readFileSync("./teachermap.json"));
|
||||
const teachermap: Record<string, string> = JSON.parse(fs.readFileSync("./tests/teachermap.json", "utf8"));
|
||||
|
||||
test("Me", [
|
||||
{
|
||||
@@ -232,6 +232,7 @@ test("za Vn zastupuje Jk", [
|
||||
teacher: "Ing. Zdeněk Vondra",
|
||||
teacherCode: "vn",
|
||||
type: "zastoupen",
|
||||
hours: null,
|
||||
zastupuje: {
|
||||
teacher: "David Janoušek",
|
||||
teacherCode: "jk",
|
||||
@@ -257,18 +258,18 @@ test("Sv-5-exk", [
|
||||
},
|
||||
]);
|
||||
|
||||
function test(input, expectedOutput) {
|
||||
function test(input: string, expectedOutput: any[]) {
|
||||
const res = parseAbsence(input, teachermap);
|
||||
|
||||
if (!deepEqual(res, expectedOutput)) {
|
||||
console.error("ERROR for input: " + input);
|
||||
console.log(res);
|
||||
console.log(expectedOutput);
|
||||
console.log(JSON.stringify(res, null, 2));
|
||||
console.log(JSON.stringify(expectedOutput, null, 2));
|
||||
console.log();
|
||||
}
|
||||
}
|
||||
|
||||
function deepEqual(a, b) {
|
||||
function deepEqual(a: any, b: any): boolean {
|
||||
if (a === b) return true;
|
||||
|
||||
if (
|
||||
Reference in New Issue
Block a user