Add missing css_classes unit test

This commit is contained in:
bjoluc 2022-11-08 16:49:36 +01:00
parent 46a3b65cb6
commit b6e096a1cc
2 changed files with 18 additions and 2 deletions

View File

@ -144,6 +144,24 @@ describe("Trial", () => {
}); });
}); });
it("respects the `css_classes` trial parameter", async () => {
const displayElement = dependencies.getDisplayElement();
let trial = createTrial({ type: TestPlugin, css_classes: "class1" });
expect(displayElement.classList.value).toEqual("");
trial.run();
expect(displayElement.classList.value).toEqual("class1");
await TestPlugin.finishTrial();
expect(displayElement.classList.value).toEqual("");
trial = createTrial({ type: TestPlugin, css_classes: ["class1", "class2"] });
expect(displayElement.classList.value).toEqual("");
trial.run();
expect(displayElement.classList.value).toEqual("class1 class2");
await TestPlugin.finishTrial();
expect(displayElement.classList.value).toEqual("");
});
it("invokes the local `on_finish` callback with the result data", async () => { it("invokes the local `on_finish` callback with the result data", async () => {
const onFinishCallback = jest.fn(); const onFinishCallback = jest.fn();
const trial = createTrial({ type: TestPlugin, on_finish: onFinishCallback }); const trial = createTrial({ type: TestPlugin, on_finish: onFinishCallback });

View File

@ -115,8 +115,6 @@ export class Trial extends TimelineNode {
); );
} }
// TODO there were `Trial` unit tests for css classes once => restore them!
/** /**
* Add the CSS classes from the `css_classes` parameter to the display element * Add the CSS classes from the `css_classes` parameter to the display element
*/ */