-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
progress: fix test by mocking Web Worker
- Loading branch information
Showing
4 changed files
with
21 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
import { Suspense } from 'react' | ||
import { expect, test } from 'vitest' | ||
import { render, screen } from '@testing-library/react' | ||
|
||
import App from '.' | ||
import Page from './+Page' | ||
|
||
test('renders without crashing', () => { | ||
render(<Suspense fallback="loading"><App /></Suspense>) | ||
render(<Suspense fallback="loading"><Page /></Suspense>) | ||
expect(screen.getByText('flash.comma.ai')).toBeInTheDocument() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class MockWorker { | ||
constructor(stringUrl) { | ||
this.url = stringUrl; | ||
this.onmessage = () => {}; | ||
} | ||
|
||
postMessage(msg) { | ||
this.onmessage({ data: msg }); | ||
} | ||
|
||
addEventListener() {} | ||
removeEventListener() {} | ||
terminate() {} | ||
} | ||
|
||
export default MockWorker; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
import '@testing-library/jest-dom' | ||
import MockWorker from './mockWorker'; | ||
|
||
global.Worker = MockWorker |