Files
zkldi_Tachi/server/src/utils/session.test.ts
T
zkldi cad860413e fix: make all tests pass
I'm sorry for how disgustingly large all of these commits are. I promise
that this is the last time something this disgusting will happen.

This is a mono-patch for various things that were broken by the major
refactor. It's mostly things like error messages now being different
(and tests failing as a result).

Some notable fixes include me accidentally deleting the entire DELETE
api-tokens endpoint (lol), and timeAchieved: 0 in batch-manual not
coercing to null anymore. It appears the behaviour was intentional for
some reason. I'm not sure why though.
2022-05-31 17:56:14 +01:00

31 lines
701 B
TypeScript

import { GetScoresFromSession } from "./session";
import db from "external/mongo/db";
import t from "tap";
import ResetDBState from "test-utils/resets";
t.test("#GetScoresFromSession", async (t) => {
t.beforeEach(ResetDBState);
await ResetDBState();
const exampleSession = await db.sessions.findOne();
const 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();
});