Files
zkldi_Tachi/server/src/core/session.test.ts
T
2021-05-13 09:33:51 +01:00

31 lines
815 B
TypeScript

import t from "tap";
import db, { CloseMongoConnection } from "../db/db";
import ResetDBState from "../test-utils/reset-db-state";
import { GetScoresFromSession } from "./session";
t.test("#GetScoresFromSession", async (t) => {
t.beforeEach(ResetDBState);
let exampleSession = await db.sessions.findOne();
let scores = await GetScoresFromSession(exampleSession!);
t.equal(
scores.length,
exampleSession!.scoreInfo.length,
"Should return the same amount of scores as the session."
);
for (let i = 0; i < exampleSession!.scoreInfo.length; i++) {
t.equal(
scores[i].scoreID,
exampleSession!.scoreInfo[i].scoreID,
"Should return the scores requested."
);
}
t.end();
});
t.teardown(CloseMongoConnection);