Skip to content

Commit 0b78155

Browse files
committed
remove unnecessary helper function
1 parent c8bda3c commit 0b78155

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

packages/jspsych/tests/core/progressbar.test.ts

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ import { pressKey, startTimeline } from "@jspsych/test-utils";
33

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

6-
// progress bar lives in the container element
7-
const getContainer = (jsPsych: JsPsych) => {
8-
return jsPsych.getDisplayContainerElement();
9-
}
10-
116
describe("automatic progress bar", () => {
127
test("progress bar does not display by default", async () => {
138
const { jsPsych } = await startTimeline([
@@ -17,8 +12,8 @@ describe("automatic progress bar", () => {
1712
},
1813
]);
1914

20-
const displayContainer = getContainer(jsPsych);
21-
expect(displayContainer.querySelector("#jspsych-progressbar-container")).toBeNull();
15+
expect(jsPsych.getDisplayContainerElement().querySelector("#jspsych-progressbar-container"))
16+
.toBeNull();
2217
await pressKey("a");
2318
});
2419

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

36-
const displayContainer = getContainer(jsPsych);
37-
expect(displayContainer.querySelector("#jspsych-progressbar-container").innerHTML).toMatch(
38-
'<span>Completion Progress</span><div id="jspsych-progressbar-outer"><div id="jspsych-progressbar-inner" style="width: 0%;"></div></div>'
39-
);
31+
expect(jsPsych.getDisplayContainerElement().querySelector("#jspsych-progressbar-container").innerHTML)
32+
.toMatch(
33+
'<span>Completion Progress</span><div id="jspsych-progressbar-outer"><div id="jspsych-progressbar-inner" style="width: 0%;"></div></div>'
34+
);
4035
});
4136

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

53-
const displayContainer = getContainer(jsPsych);
54-
const progressbarElement = displayContainer.querySelector<HTMLElement>("#jspsych-progressbar-inner");
48+
const progressbarElement =
49+
jsPsych.getDisplayContainerElement().querySelector<HTMLElement>("#jspsych-progressbar-inner");
5550

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

78-
const displayContainer = getContainer(jsPsych);
79-
const progressbarElement = displayContainer.querySelector<HTMLElement>("#jspsych-progressbar-inner");
73+
const progressbarElement =
74+
jsPsych.getDisplayContainerElement().querySelector<HTMLElement>("#jspsych-progressbar-inner");
8075

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

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

113-
const displayContainer = getContainer(jsPsych);
114-
const progressbarElement = displayContainer.querySelector<HTMLElement>("#jspsych-progressbar-inner");
108+
const progressbarElement =
109+
jsPsych.getDisplayContainerElement().querySelector<HTMLElement>("#jspsych-progressbar-inner");
115110

116111
expect(progressbarElement.style.width).toEqual("0%");
117112
await pressKey("a");

0 commit comments

Comments
 (0)