Skip to content

Commit f02c0eb

Browse files
committed
test: restore compatibility with upstream test changes
- fix addEventListener spy usage in trash tests - add ErrorHandler mocks for IntervalsBlocks tests - update canvas and DOM test mocks after rebase - resolve test failures introduced during conflict resolution
1 parent dab0d5c commit f02c0eb

4 files changed

Lines changed: 28 additions & 1 deletion

File tree

js/__tests__/IntervalsBlocks.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ global.Singer = {
103103
}
104104
};
105105

106+
global.ErrorHandler = {
107+
warn: jest.fn(),
108+
error: jest.fn()
109+
};
110+
106111
const { setupIntervalsBlocks } = require("../blocks/IntervalsBlocks.js");
107112

108113
function makeTurSinger(overrides = {}) {

js/__tests__/trash.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@ describe("Trashcan Class", () => {
112112
});
113113

114114
it("should resize and debounce the event listener", () => {
115-
jest.spyOn(window, "addEventListener").mockImplementation(() => {});
115+
const addEventListenerSpy = jest
116+
.spyOn(window, "addEventListener")
117+
.mockImplementation(() => {});
116118
trashcan.resizeEvent(1);
117119
const resizeFn = addEventListenerSpy.mock.calls[0][1];
118120
resizeFn(); // simulate resize

js/blocks/__tests__/IntervalsBlocks.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222

2323
const { setupIntervalsBlocks } = require("../IntervalsBlocks");
2424

25+
global.ErrorHandler = {
26+
warn: jest.fn(),
27+
error: jest.fn()
28+
};
29+
2530
describe("setupIntervalsBlocks", () => {
2631
let activity;
2732
let logo;

test/setupTests.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,20 @@ afterEach(() => {
33
jest.restoreAllMocks();
44
});
55

6+
HTMLCanvasElement.prototype.getContext = jest.fn(() => ({
7+
rect: jest.fn(),
8+
getImageData: jest.fn(() => ({ data: [] })),
9+
putImageData: jest.fn(),
10+
beginPath: jest.fn(),
11+
moveTo: jest.fn(),
12+
lineTo: jest.fn(),
13+
stroke: jest.fn(),
14+
closePath: jest.fn(),
15+
arc: jest.fn(),
16+
fill: jest.fn(),
17+
clearRect: jest.fn(),
18+
canvas: { width: 800, height: 600 }
19+
}));
20+
621
// Minimal globals (ONLY safe defaults)
722
global.requestAnimationFrame = cb => setTimeout(cb, 0);

0 commit comments

Comments
 (0)