Skip to content

Commit

Permalink
test: add educator service test suite
Browse files Browse the repository at this point in the history
ref virtualcommons#943

Co-authored-by: Sabrina Nelson <[email protected]>
Co-authored-by: Kelly Tran <[email protected]>
Co-authored-by: Allen Lee <[email protected]>
  • Loading branch information
4 people committed Jun 11, 2024
1 parent c3e2de8 commit 9865a3b
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions server/tests/services/educator.test.ts
Original file line number Diff line number Diff line change
@@ -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(
"[email protected]",
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));
});

0 comments on commit 9865a3b

Please sign in to comment.