Skip to content

Commit 38b0b3d

Browse files
authored
test(v2/runtime): fix vitest mock API usage in events tests (#5579)
* test(v2/runtime): fix vitest mock API usage in events tests Three tests in desktop/events.test.js read mock invocations via window.WailsInvoke.calls, which is the pre-1.0 vitest/jest spy shape; modern vitest exposes them at .mock.calls, so the property was undefined and the tests failed on every run ('should emit an event' and both EventsOff/EventsOffAll cases). The suite has been red on master independent of any product change. Use .mock.calls. All 11 tests now pass; no product code touched. * chore: remove UNRELEASED_CHANGELOG.md to avoid merge conflicts
1 parent 99f9b5f commit 38b0b3d

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

v2/internal/frontend/runtime/desktop/events.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ describe('EventsEmit', () => {
8383
it('should emit an event', () => {
8484
EventsEmit('a', 'one', 'two', 'three')
8585
expect(window.WailsInvoke).toBeCalledTimes(1);
86-
const calledWith = window.WailsInvoke.calls[0][0];
86+
const calledWith = window.WailsInvoke.mock.calls[0][0];
8787
expect(calledWith.slice(0, 2)).toBe('EE')
8888
expect(JSON.parse(calledWith.slice(2))).toStrictEqual({data: ["one", "two", "three"], name: "a"})
8989
})
@@ -113,7 +113,7 @@ describe('EventsOff', () => {
113113
expect(eventListeners['b']).toBeUndefined()
114114
expect(eventListeners['c']).not.toBeUndefined()
115115
expect(window.WailsInvoke).toBeCalledTimes(2);
116-
expect(window.WailsInvoke.calls).toStrictEqual([['EXa'], ['EXb']]);
116+
expect(window.WailsInvoke.mock.calls).toStrictEqual([['EXa'], ['EXb']]);
117117
})
118118
})
119119

@@ -127,7 +127,7 @@ describe('EventsOffAll', () => {
127127
EventsOffAll()
128128
expect(eventListeners).toStrictEqual({})
129129
expect(window.WailsInvoke).toBeCalledTimes(3);
130-
expect(window.WailsInvoke.calls).toStrictEqual([['EXa'], ['EXb'], ['EXc']]);
130+
expect(window.WailsInvoke.mock.calls).toStrictEqual([['EXa'], ['EXb'], ['EXc']]);
131131
})
132132
})
133133

0 commit comments

Comments
 (0)