From f71c5fc13ec510eb2103e5e204d8002185ea8d04 Mon Sep 17 00:00:00 2001 From: sgfost Date: Tue, 11 Jun 2024 15:48:09 -0700 Subject: [PATCH] test: add educator service test suite ref #943 Co-authored-by: Sabrina Nelson Co-authored-by: Kelly Tran Co-authored-by: Allen Lee --- server/tests/services/educator.test.ts | 54 ++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 server/tests/services/educator.test.ts diff --git a/server/tests/services/educator.test.ts b/server/tests/services/educator.test.ts new file mode 100644 index 000000000..4fea75bfd --- /dev/null +++ b/server/tests/services/educator.test.ts @@ -0,0 +1,54 @@ +import { AccountService } from "@port-of-mars/server/services/account"; +import { User, Teacher, Tournament } from "@port-of-mars/server/entity"; +import { settings } from "@port-of-mars/server/settings"; +import { Connection, EntityManager, QueryRunner } from "typeorm"; +import { ServiceProvider } from "@port-of-mars/server/services"; +import { ServerError } from "@port-of-mars/server/util"; +import { createTournament, initTransaction, rollbackTransaction } from "../common"; +import { EducatorService } from "@port-of-mars/server/services/educator"; + +describe("the educator service", () => { + let conn: Connection; + let qr: QueryRunner; + let manager: EntityManager; + let sp: ServiceProvider; + let t: Tournament; + let accountService: AccountService; + let educatorService: EducatorService; + const teacherUsername = "teacher1"; + let teacher: Teacher; + + beforeAll(async () => { + [conn, qr, manager] = await initTransaction(); + sp = new ServiceProvider(qr.manager); + accountService = sp.account; + educatorService = sp.educator; + teacher = await educatorService.createTeacher( + "teacher1@example.com", + teacherUsername, + "Teacher One" + ); + }); + + it("generates a unique student passcode", async () => { + const rejoinCodes = []; + for (let i = 0; i < 10; i++) { + const rejoinCode = await educatorService.generateStudentRejoinCode(); + console.log("student rejoin code: ", rejoinCode); + expect(rejoinCodes.includes(rejoinCode)).toBe(false); + rejoinCodes.push(rejoinCode); + } + }); + + it("generates a unique authToken (game code) for a classroom", async () => { + // TODO: + expect(true).toBe(true); + }); + + it("generates a unique educator password", async () => { + // TODO: + expect(true).toBe(true); + }); + + afterAll(async () => rollbackTransaction(conn, qr)); +});