Skip to content

Commit

Permalink
debug: throw error once only
Browse files Browse the repository at this point in the history
  • Loading branch information
goosewobbler committed Oct 9, 2024
1 parent 8ff644c commit 5dc4a01
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions e2e/api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -702,29 +702,29 @@ describe('browser.electron', () => {
});

describe('mock.results', () => {
// it('should return the results of the mock execution', async () => {
// const mockGetName = await browser.electron.mock('app', 'getName');

// // TODO: why does `mockReturnValueOnce` not work for returning 'result' here?
// await mockGetName.mockImplementationOnce(() => 'result');
// await mockGetName.mockImplementation(() => {
// throw new Error('thrown error');
// });

// await expect(browser.electron.execute((electron) => electron.app.getName())).resolves.toBe('result');
// await expect(browser.electron.execute((electron) => electron.app.getName())).rejects.toThrow('thrown error');

// expect(mockGetName.mock.results).toStrictEqual([
// {
// type: 'return',
// value: 'result',
// },
// {
// type: 'throw',
// value: new Error('thrown error'),
// },
// ]);
// });
it('should return the results of the mock execution', async () => {
const mockGetName = await browser.electron.mock('app', 'getName');

await mockGetName.mockImplementationOnce(() => {
throw new Error('thrown error');
});
// TODO: why does `mockReturnValueOnce` not work for returning 'result' here?
await mockGetName.mockImplementation(() => 'result');

await expect(browser.electron.execute((electron) => electron.app.getName())).rejects.toThrow('thrown error');
await expect(browser.electron.execute((electron) => electron.app.getName())).resolves.toBe('result');

expect(mockGetName.mock.results).toStrictEqual([
{
type: 'throw',
value: new Error('thrown error'),
},
{
type: 'return',
value: 'result',
},
]);
});

it('should return an empty array when the mock was never invoked', async () => {
const mockGetName = await browser.electron.mock('app', 'getName');
Expand Down

0 comments on commit 5dc4a01

Please sign in to comment.