forked from virtualcommons/port-of-mars
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add educator service test suite
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
1 parent
4181569
commit f71c5fc
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
}); |