Skip to content

Commit

Permalink
remove unnecessary helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
jadeddelta committed Jan 10, 2025
1 parent c8bda3c commit 0b78155
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions packages/jspsych/tests/core/progressbar.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ import { pressKey, startTimeline } from "@jspsych/test-utils";

import { initJsPsych, JsPsych } from "../../src";

// progress bar lives in the container element
const getContainer = (jsPsych: JsPsych) => {
return jsPsych.getDisplayContainerElement();
}

describe("automatic progress bar", () => {
test("progress bar does not display by default", async () => {
const { jsPsych } = await startTimeline([
Expand All @@ -17,8 +12,8 @@ describe("automatic progress bar", () => {
},
]);

const displayContainer = getContainer(jsPsych);
expect(displayContainer.querySelector("#jspsych-progressbar-container")).toBeNull();
expect(jsPsych.getDisplayContainerElement().querySelector("#jspsych-progressbar-container"))
.toBeNull();
await pressKey("a");
});

Expand All @@ -33,10 +28,10 @@ describe("automatic progress bar", () => {
{ show_progress_bar: true }
);

const displayContainer = getContainer(jsPsych);
expect(displayContainer.querySelector("#jspsych-progressbar-container").innerHTML).toMatch(
'<span>Completion Progress</span><div id="jspsych-progressbar-outer"><div id="jspsych-progressbar-inner" style="width: 0%;"></div></div>'
);
expect(jsPsych.getDisplayContainerElement().querySelector("#jspsych-progressbar-container").innerHTML)
.toMatch(
'<span>Completion Progress</span><div id="jspsych-progressbar-outer"><div id="jspsych-progressbar-inner" style="width: 0%;"></div></div>'
);
});

test("progress bar automatically updates by default", async () => {
Expand All @@ -50,8 +45,8 @@ describe("automatic progress bar", () => {
{ show_progress_bar: true }
);

const displayContainer = getContainer(jsPsych);
const progressbarElement = displayContainer.querySelector<HTMLElement>("#jspsych-progressbar-inner");
const progressbarElement =
jsPsych.getDisplayContainerElement().querySelector<HTMLElement>("#jspsych-progressbar-inner");

expect(progressbarElement.style.width).toEqual("0%");
await pressKey("a");
Expand All @@ -75,8 +70,8 @@ describe("automatic progress bar", () => {
auto_update_progress_bar: false,
});

const displayContainer = getContainer(jsPsych);
const progressbarElement = displayContainer.querySelector<HTMLElement>("#jspsych-progressbar-inner");
const progressbarElement =
jsPsych.getDisplayContainerElement().querySelector<HTMLElement>("#jspsych-progressbar-inner");

for (let i = 0; i < 4; i++) {
expect(progressbarElement.style.width).toEqual("0%");
Expand Down Expand Up @@ -110,8 +105,8 @@ describe("automatic progress bar", () => {

const { jsPsych } = await startTimeline(timeline, jsPsychObject);

const displayContainer = getContainer(jsPsych);
const progressbarElement = displayContainer.querySelector<HTMLElement>("#jspsych-progressbar-inner");
const progressbarElement =
jsPsych.getDisplayContainerElement().querySelector<HTMLElement>("#jspsych-progressbar-inner");

expect(progressbarElement.style.width).toEqual("0%");
await pressKey("a");
Expand Down

0 comments on commit 0b78155

Please sign in to comment.