mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 15:48:32 -06:00
deterministic lecture stringification
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
import { describe, it, expect, beforeEach } from "vitest";
|
||||
import { promises as fs } from "fs";
|
||||
import {
|
||||
DayOfWeek,
|
||||
LocalCourseSettings,
|
||||
} from "@/models/local/localCourse";
|
||||
import { DayOfWeek, LocalCourseSettings } from "@/models/local/localCourse";
|
||||
import { fileStorageService } from "../fileStorage/fileStorageService";
|
||||
|
||||
describe("FileStorageTests", () => {
|
||||
@@ -30,7 +27,7 @@ describe("FileStorageTests", () => {
|
||||
canvasId: 0,
|
||||
defaultAssignmentSubmissionTypes: [],
|
||||
defaultFileUploadTypes: [],
|
||||
holidays: {}
|
||||
holidays: [],
|
||||
};
|
||||
|
||||
await fileStorageService.settings.updateCourseSettings(name, settings);
|
||||
|
||||
40
nextjs/src/services/tests/lectureStorage.test.ts
Normal file
40
nextjs/src/services/tests/lectureStorage.test.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
lectureToString,
|
||||
parseLecture,
|
||||
} from "../fileStorage/lectureFileStorageService";
|
||||
import { Lecture } from "@/models/local/lecture";
|
||||
|
||||
describe("can parse and stringify lectures", () => {
|
||||
it("can parse lecture", () => {
|
||||
const rawLecture = `
|
||||
Name: some name
|
||||
Date: 6/22/2024
|
||||
---
|
||||
this is the lecture
|
||||
|
||||
|
||||
content`;
|
||||
const parsed = parseLecture(rawLecture);
|
||||
expect(parsed.name).toBe("some name");
|
||||
expect(parsed.date).toBe("6/22/2024");
|
||||
expect(parsed.content).toBe(`this is the lecture
|
||||
|
||||
|
||||
content`);
|
||||
});
|
||||
|
||||
it("parsing and stringification is deterministic", () => {
|
||||
const lecture: Lecture = {
|
||||
name: "test lecture",
|
||||
date: "06/*22/2024",
|
||||
content: `some content
|
||||
- with
|
||||
- a
|
||||
- list`,
|
||||
};
|
||||
const rawLecture = lectureToString(lecture);
|
||||
const parsedLecture = parseLecture(rawLecture);
|
||||
expect(parsedLecture).toStrictEqual(lecture);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user