Skip to content

Commit 72914c8

Browse files
committed
linting
1 parent 128cde0 commit 72914c8

File tree

1 file changed

+59
-59
lines changed

1 file changed

+59
-59
lines changed

js/__tests__/toolbar.test.js

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ global.jQuery = jest.fn(() => ({
99
on: jest.fn(),
1010
trigger: jest.fn(),
1111
tooltip: jest.fn(),
12-
dropdown: jest.fn(),
12+
dropdown: jest.fn()
1313
}));
1414
global.jQuery.noConflict = jest.fn(() => global.jQuery);
1515

1616
global.window = {
1717
localStorage: { languagePreference: "en" },
1818
navigator: { language: "en-US" },
1919
document: {
20-
getElementById: jest.fn(() => ({ style: {} })),
21-
},
20+
getElementById: jest.fn(() => ({ style: {} }))
21+
}
2222
};
2323

2424
global.localStorage = window.localStorage;
@@ -31,7 +31,7 @@ global.document.getElementById = jest.fn((id) => ({
3131
setAttribute: jest.fn(),
3232
innerHTML: "",
3333
classList: { add: jest.fn() },
34-
appendChild: jest.fn(),
34+
appendChild: jest.fn()
3535
}));
3636

3737
global.docById = jest.fn((id) => ({
@@ -40,15 +40,14 @@ global.docById = jest.fn((id) => ({
4040
innerHTML: "",
4141
style: {},
4242
classList: { add: jest.fn() },
43-
appendChild: jest.fn(),
43+
appendChild: jest.fn()
4444
}));
4545

46-
4746
global._ = jest.fn((str) => str);
4847

4948
global.$j = jest.fn(() => ({
5049
tooltip: jest.fn(),
51-
dropdown: jest.fn(),
50+
dropdown: jest.fn()
5251
}));
5352

5453
describe("Toolbar Class", () => {
@@ -134,7 +133,7 @@ describe("Toolbar Class", () => {
134133

135134
beforeEach(() => {
136135
jest.useFakeTimers();
137-
jest.spyOn(global, 'clearTimeout');
136+
jest.spyOn(global, "clearTimeout");
138137

139138
global.saveButton = {
140139
disabled: false,
@@ -161,7 +160,7 @@ describe("Toolbar Class", () => {
161160
}
162161
};
163162

164-
global.docById = jest.fn(id => elements[id]);
163+
global.docById = jest.fn((id) => elements[id]);
165164
global.document = {
166165
body: {
167166
style: {
@@ -194,8 +193,8 @@ describe("Toolbar Class", () => {
194193
// Japanese language
195194
toolbar.language = "ja";
196195
toolbar.renderLogoIcon(mockOnClick);
197-
expect(elements["mb-logo"].innerHTML).toContain('logo-ja.svg');
198-
expect(elements["mb-logo"].innerHTML).toContain('transform: scale(0.85)');
196+
expect(elements["mb-logo"].innerHTML).toContain("logo-ja.svg");
197+
expect(elements["mb-logo"].innerHTML).toContain("transform: scale(0.85)");
199198
elements["mb-logo"].onclick();
200199
expect(mockOnClick).toHaveBeenCalledTimes(2);
201200
});
@@ -217,7 +216,7 @@ describe("Toolbar Class", () => {
217216
}
218217
};
219218

220-
global.docById.mockImplementation(id => elements[id] || {});
219+
global.docById.mockImplementation((id) => elements[id] || {});
221220

222221
const mockActivity = {
223222
hideMsgs: jest.fn(),
@@ -235,10 +234,7 @@ describe("Toolbar Class", () => {
235234
expect(global.saveButtonAdvanced.disabled).toBe(true);
236235
expect(global.saveButton.className).toBe("grey-text inactiveLink");
237236
expect(elements.record.className).toBe("grey-text inactiveLink");
238-
expect(elements.stop.addEventListener).toHaveBeenCalledWith(
239-
"click",
240-
expect.any(Function)
241-
);
237+
expect(elements.stop.addEventListener).toHaveBeenCalledWith("click", expect.any(Function));
242238

243239
const stopClickHandler = elements.stop.addEventListener.mock.calls[0][1];
244240
stopClickHandler();
@@ -249,11 +245,12 @@ describe("Toolbar Class", () => {
249245
});
250246

251247
test("renderStopIcon sets onclick and updates stop button behavior", () => {
252-
253248
const stopIcon = { onclick: null, style: { color: "" } };
254249
const recordButton = { className: "recording" };
255250

256-
global.docById.mockImplementation(id => id === "stop" ? stopIcon : id === "record" ? recordButton : {});
251+
global.docById.mockImplementation((id) =>
252+
id === "stop" ? stopIcon : id === "record" ? recordButton : {}
253+
);
257254

258255
const mockOnClick = jest.fn();
259256
toolbar.renderStopIcon(mockOnClick);
@@ -279,9 +276,9 @@ describe("Toolbar Class", () => {
279276
appendChild: jest.fn()
280277
}
281278
};
282-
global.docById = jest.fn(id => elements[id]);
279+
global.docById = jest.fn((id) => elements[id]);
283280
global.document = {
284-
createElement: jest.fn(tagName => ({
281+
createElement: jest.fn((tagName) => ({
285282
tagName,
286283
classList: { add: jest.fn() },
287284
textContent: "",
@@ -290,7 +287,7 @@ describe("Toolbar Class", () => {
290287
appendChild: jest.fn()
291288
}))
292289
};
293-
global._ = jest.fn(str => str);
290+
global._ = jest.fn((str) => str);
294291
const toolbar = new Toolbar();
295292
toolbar.activity = mockActivity;
296293

@@ -348,7 +345,6 @@ describe("Toolbar Class", () => {
348345
});
349346

350347
test("renderWrapIcon toggles WRAP and updates tooltip", () => {
351-
352348
const mockActivity = {
353349
helpfulWheelItems: [
354350
{ label: "Turtle Wrap Off", display: false },
@@ -395,12 +391,12 @@ describe("Toolbar Class", () => {
395391
style: { display: "block" }
396392
};
397393

398-
global._ = jest.fn(str => str);
394+
global._ = jest.fn((str) => str);
399395
global.$j = jest.fn(() => ({
400396
tooltip: jest.fn()
401397
}));
402398
global.WRAP = false;
403-
global.docById = jest.fn(id => {
399+
global.docById = jest.fn((id) => {
404400
if (id === "wrapTurtle") return wrapIcon;
405401
if (id === "helpfulWheelDiv") return helpfulWheelDiv;
406402
return {};
@@ -419,10 +415,9 @@ describe("Toolbar Class", () => {
419415
});
420416

421417
test("renderSaveIcons handles all save button states correctly", () => {
422-
423418
const elements = {
424-
saveButton: { onclick: null, style: { display: "" } },
425-
saveButtonAdvanced: { onclick: null, style: { display: "" } },
419+
"saveButton": { onclick: null, style: { display: "" } },
420+
"saveButtonAdvanced": { onclick: null, style: { display: "" } },
426421
"save-html-beg": { onclick: null },
427422
"save-png-beg": { onclick: null, disabled: false, className: "" },
428423
"save-html": { onclick: null },
@@ -437,7 +432,7 @@ describe("Toolbar Class", () => {
437432
"save-blockartwork-png": { onclick: null }
438433
};
439434

440-
global.docById = jest.fn(id => elements[id] || { onclick: null });
435+
global.docById = jest.fn((id) => elements[id] || { onclick: null });
441436

442437
const mockActivity = {
443438
beginnerMode: true,
@@ -520,7 +515,11 @@ describe("Toolbar Class", () => {
520515
});
521516

522517
test("updateRecordButton hides record button", () => {
523-
const recordButton = { classList: { add: jest.fn() }, style: { display: "" }, innerHTML: "" };
518+
const recordButton = {
519+
classList: { add: jest.fn() },
520+
style: { display: "" },
521+
innerHTML: ""
522+
};
524523
global.docById.mockReturnValue(recordButton);
525524
global.fnBrowserDetect = jest.fn(() => "firefox");
526525
toolbar.updateRecordButton(jest.fn());
@@ -529,7 +528,6 @@ describe("Toolbar Class", () => {
529528
});
530529

531530
test("renderPlanetIcon sets onclick and updates planet icon behavior", () => {
532-
533531
const elements = {
534532
planetIcon: {
535533
onclick: null,
@@ -549,7 +547,7 @@ describe("Toolbar Class", () => {
549547
}
550548
};
551549

552-
global.docById.mockImplementation(id => elements[id] || {});
550+
global.docById.mockImplementation((id) => elements[id] || {});
553551

554552
const mockOnClick = jest.fn();
555553
toolbar.activity = {};
@@ -569,33 +567,32 @@ describe("Toolbar Class", () => {
569567
});
570568

571569
test("renderMenuIcon toggles menu visibility", () => {
572-
573570
const elements = {
574-
menu: {
571+
"menu": {
575572
onclick: null,
576573
innerHTML: "",
577574
style: {}
578575
},
579576
"aux-toolbar": {
580577
style: { display: "" }
581578
},
582-
search: {
579+
"search": {
583580
classList: {
584581
toggle: jest.fn()
585582
}
586583
},
587-
toggleAuxBtn: {
584+
"toggleAuxBtn": {
588585
className: ""
589586
},
590-
chooseKeyDiv: {
587+
"chooseKeyDiv": {
591588
style: { display: "" }
592589
},
593-
movable: {
590+
"movable": {
594591
style: { display: "" }
595592
}
596593
};
597594

598-
global.docById.mockImplementation(id => elements[id] || {});
595+
global.docById.mockImplementation((id) => elements[id] || {});
599596

600597
const mockOnClick = jest.fn();
601598
toolbar.activity = {};
@@ -630,7 +627,7 @@ describe("Toolbar Class", () => {
630627
style: { color: "" }
631628
};
632629

633-
global.docById.mockImplementation(id => {
630+
global.docById.mockImplementation((id) => {
634631
if (id === "runSlowlyIcon") return runSlowlyIcon;
635632
if (id === "stop") return stopIcon;
636633
return {};
@@ -687,7 +684,7 @@ describe("Toolbar Class", () => {
687684
saveButtonAdvanced: { style: { display: "" } }
688685
};
689686

690-
global.docById = jest.fn(id => elements[id]);
687+
global.docById = jest.fn((id) => elements[id]);
691688
global.localStorage = { setItem: jest.fn() };
692689
global.$j = jest.fn(() => ({
693690
tooltip: jest.fn(),
@@ -699,9 +696,7 @@ describe("Toolbar Class", () => {
699696

700697
const mockActivity = {
701698
beginnerMode: true,
702-
helpfulWheelItems: [
703-
{ label: "Enable horizontal scrolling", display: false }
704-
],
699+
helpfulWheelItems: [{ label: "Enable horizontal scrolling", display: false }],
705700
palettes: { updatePalettes: jest.fn() },
706701
refreshCanvas: jest.fn(),
707702
save: {
@@ -744,14 +739,19 @@ describe("Toolbar Class", () => {
744739
mockCallbacks.setScroller
745740
);
746741

747-
expect(elements.beginnerMode.style.display).toBe('none');
748-
expect(elements.advancedMode.style.display).toBe('block');
749-
expect(elements.record.style.display).toBe('none');
750-
751-
['displayStatsIcon', 'loadPluginIcon', 'delPluginIcon',
752-
'enableHorizScrollIcon', 'toggleJavaScriptIcon'].forEach(iconId => {
753-
expect(elements[iconId].style.display).toBe('none');
754-
});
742+
expect(elements.beginnerMode.style.display).toBe("none");
743+
expect(elements.advancedMode.style.display).toBe("block");
744+
expect(elements.record.style.display).toBe("none");
745+
746+
[
747+
"displayStatsIcon",
748+
"loadPluginIcon",
749+
"delPluginIcon",
750+
"enableHorizScrollIcon",
751+
"toggleJavaScriptIcon"
752+
].forEach((iconId) => {
753+
expect(elements[iconId].style.display).toBe("none");
754+
});
755755

756756
expect(mockActivity.helpfulWheelItems[0].display).toBe(false);
757757
const renderSaveIconsArgs = mockActivity.toolbar.renderSaveIcons.mock.calls[0];
@@ -792,7 +792,9 @@ describe("Toolbar Class", () => {
792792

793793
test("renderRunStepIcon sets onclick and handles Japanese beginner mode", () => {
794794
const runStepByStepIcon = { onclick: null, style: { display: "" } };
795-
global.docById.mockImplementation(id => id === "runStepByStepIcon" ? runStepByStepIcon : {});
795+
global.docById.mockImplementation((id) =>
796+
id === "runStepByStepIcon" ? runStepByStepIcon : {}
797+
);
796798

797799
const mockActivity = { beginnerMode: false };
798800
const toolbar = new Toolbar();
@@ -836,7 +838,7 @@ describe("Toolbar Class", () => {
836838
test("renderChooseKeyIcon sets onclick and toggles key selection visibility", () => {
837839
const chooseKeyIcon = { onclick: null };
838840
const chooseKeyDiv = { style: { display: "none" } };
839-
global.docById.mockImplementation(id => {
841+
global.docById.mockImplementation((id) => {
840842
if (id === "chooseKeyIcon") return chooseKeyIcon;
841843
if (id === "chooseKeyDiv") return chooseKeyDiv;
842844
return {};
@@ -881,20 +883,18 @@ describe("Toolbar Class", () => {
881883
});
882884

883885
test("closeAuxToolbar hides auxiliary toolbar if visible", () => {
884-
885886
const elements = {
886887
"aux-toolbar": { style: { display: "block" } },
887-
menu: { innerHTML: "" },
888-
toggleAuxBtn: { className: "some-class blue darken-1" }
888+
"menu": { innerHTML: "" },
889+
"toggleAuxBtn": { className: "some-class blue darken-1" }
889890
};
890891

891-
global.docById.mockImplementation(id => elements[id] || {});
892+
global.docById.mockImplementation((id) => elements[id] || {});
892893
const mockOnClick = jest.fn();
893894
toolbar.activity = {};
894895
toolbar.closeAuxToolbar(mockOnClick);
895896
expect(elements["aux-toolbar"].style.display).toBe("none");
896897
expect(elements.menu.innerHTML).toBe("menu");
897898
expect(mockOnClick).toHaveBeenCalledWith(toolbar.activity, false);
898899
});
899-
900-
});
900+
});

0 commit comments

Comments
 (0)