test(frontend): Testen voor leerobject-controllers + opvragen van leerpaden a.d.h.v. admin
This commit is contained in:
parent
759282f1c6
commit
694155cc1e
2 changed files with 34 additions and 0 deletions
|
@ -0,0 +1,28 @@
|
|||
import { LearningObjectController } from "../../src/controllers/learning-objects";
|
||||
import { Language } from "@dwengo-1/common/util/language";
|
||||
import { beforeEach, describe, expect, it } from "vitest";
|
||||
|
||||
describe("Test controller learning object", () => {
|
||||
let controller: LearningObjectController;
|
||||
|
||||
beforeEach(async () => {
|
||||
controller = new LearningObjectController();
|
||||
});
|
||||
|
||||
it("can get the metadata of a learning object", async () => {
|
||||
const result = await controller.getMetadata("u_id01", Language.English, 1);
|
||||
expect(result).not.toBeNull();
|
||||
for (const property of ["hruid", "version", "language", "title"]) {
|
||||
expect(result).toHaveProperty(property);
|
||||
}
|
||||
expect(result.hruid).toEqual("u_id01");
|
||||
expect(result.version).toEqual(1);
|
||||
expect(result.language).toEqual(Language.English);
|
||||
});
|
||||
|
||||
it("can get the HTML of a learning object", async () => {
|
||||
const result = await controller.getHTML("u_id01", Language.English, 1);
|
||||
expect(result).toHaveProperty("body");
|
||||
expect(result.body).toHaveProperty("innerHTML");
|
||||
});
|
||||
});
|
|
@ -18,4 +18,10 @@ describe("Test controller learning paths", () => {
|
|||
const data = await controller.getAllByTheme("kiks");
|
||||
expect(data).to.have.length.greaterThan(0);
|
||||
});
|
||||
|
||||
it("Can get all learning paths administrated by a certain user.", async () => {
|
||||
const data = await controller.getAllByAdminRaw("user");
|
||||
expect(typeof data).toEqual("array");
|
||||
expect(data.length).toBe(0); // This user does not administrate any learning paths in the test data.
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue