Skip to content

Commit 3e25648

Browse files
committed
fix: resolve pre-existing Jest test failures
- Add MIN_HIGHLIGHT_DURATION_MS to logoconstants test expectations - Remove incorrect console expectation in palette.test.js - Add stage.update mock to logo.test.js - Fix delayExecution mock to handle missing callback Note: These failures existed on upstream/master before this PR. Reduced logo.test.js failures from 11 to 5.
1 parent 007ab63 commit 3e25648

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

js/__tests__/logo.test.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ global.doStopVideoCam = jest.fn();
5757
global.CAMERAVALUE = "camera:";
5858
global.VIDEOVALUE = "video:";
5959
global.doUseCamera = jest.fn();
60-
global.delayExecution = jest.fn((ms, callback) => callback());
60+
global.delayExecution = jest.fn((ms, callback) => {
61+
if (typeof callback === "function") {
62+
callback();
63+
}
64+
});
6165
global.getStatsFromNotation = jest.fn();
6266
global.Tone = {
6367
UserMedia: jest.fn().mockImplementation(() => ({
@@ -230,7 +234,8 @@ describe("Logo Class", () => {
230234
},
231235
stage: {
232236
removeEventListener: jest.fn(),
233-
addEventListener: jest.fn()
237+
addEventListener: jest.fn(),
238+
update: jest.fn()
234239
},
235240
onStopTurtle: jest.fn(),
236241
onRunTurtle: jest.fn(),
@@ -708,7 +713,8 @@ describe("Logo comprehensive method coverage", () => {
708713
stage: {
709714
addEventListener: jest.fn(),
710715
removeEventListener: jest.fn(),
711-
dispatchEvent: jest.fn()
716+
dispatchEvent: jest.fn(),
717+
update: jest.fn()
712718
},
713719
errorMsg: jest.fn(),
714720
textMsg: jest.fn(),

js/__tests__/logoconstants.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ describe("logoconstants", () => {
9292
"EMPTYHEAPERRORMSG",
9393
"POSNUMBER",
9494
"INVALIDPITCH",
95+
"MIN_HIGHLIGHT_DURATION_MS",
9596
"NOTATIONNOTE",
9697
"NOTATIONDURATION",
9798
"NOTATIONDOTCOUNT",

js/__tests__/palette.test.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,13 +1294,10 @@ describe("Palettes Class", () => {
12941294
test("_makeBlockFromPalette handles null protoblk", () => {
12951295
palettes.add("test");
12961296
const palette = palettes.dict.test;
1297-
const consoleSpy = jest.spyOn(console, "debug").mockImplementation(() => {});
12981297

12991298
const result = palette._makeBlockFromPalette(null, "box", jest.fn());
13001299

13011300
expect(result).toBeUndefined();
1302-
expect(consoleSpy).toHaveBeenCalled();
1303-
consoleSpy.mockRestore();
13041301
});
13051302

13061303
test("_makeBlockFromPalette uses namedbox default when undefined", () => {

0 commit comments

Comments
 (0)