Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason3S committed Dec 22, 2024
1 parent 3012641 commit 5e0cef0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/_server/src/utils/catchPromise.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ describe('catchPromise', () => {
test('catchPromise with context', async () => {
const err = vi.spyOn(console, 'error').mockImplementation(() => undefined);
await expect(catchPromise(Promise.reject(Error('test')), 'Testing')).resolves.toBe(undefined);
expect(err).toHaveBeenCalledWith('%s: %s', 'Testing', expect.any(Error));
expect(err).toHaveBeenCalledWith(expect.stringContaining(`Testing: `));
});

test('catchPromise custom handler', async () => {
const err = vi.spyOn(console, 'error').mockImplementation(() => undefined);
await expect(catchPromise(Promise.reject('error'), () => 23)).resolves.toBe(23);
await expect(catchPromise(Promise.reject('error'), () => 23)).resolves.toBe(undefined);
expect(err).not.toHaveBeenCalled();
});

test('catchPromise resolve', async () => {
const err = vi.spyOn(console, 'error').mockImplementation(() => undefined);
await expect(catchPromise(Promise.resolve('msg'))).resolves.toBe('msg');
await expect(catchPromise(Promise.resolve('msg'))).resolves.toBe(undefined);
expect(err).not.toHaveBeenCalled();
});
});
1 change: 1 addition & 0 deletions vitest.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default defineConfig({
exclude: [
'**/node_modules/**',
'**/dist/**',
'**/lib/**/*.{cjs,mjs,js}',
'**/cypress/**',
'**/coverage/**',
'**/temp/**',
Expand Down

0 comments on commit 5e0cef0

Please sign in to comment.