test: proper sanity check; exclude WasmTest from coverage (#8)

This commit is contained in:
鲁树人 2023-05-18 00:30:39 +01:00
parent 4e9e360751
commit 3b26584f4d
3 changed files with 16 additions and 5 deletions

View File

@ -15,7 +15,7 @@ function App() {
<Box mt="8"> <Box mt="8">
<FileListing /> <FileListing />
</Box> </Box>
{localStorage.__dev_test === '1' && <WasmTest />} <WasmTest />
<Footer /> <Footer />
</Container> </Container>
</Box> </Box>

View File

@ -1,5 +1,6 @@
import { loadLibParakeet, BlobSink, createArrayBufferReader } from '@jixun/libparakeet'; import { loadLibParakeet, BlobSink, createArrayBufferReader } from '@jixun/libparakeet';
/* c8 ignore start: test only code */
function testWasm() { function testWasm() {
loadLibParakeet().then(async (mod) => { loadLibParakeet().then(async (mod) => {
const data = new Uint8Array(0x2000); const data = new Uint8Array(0x2000);
@ -23,9 +24,15 @@ function testWasm() {
} }
export function WasmTest() { export function WasmTest() {
// Some secret test flags...
if (localStorage.__dev_test !== '1') {
return null;
}
return ( return (
<button onClick={testWasm} type="button"> <button onClick={testWasm} type="button">
Test WASM Test WASM
</button> </button>
); );
} }
/* c8 ignore stop: test only code */

View File

@ -1,6 +1,10 @@
import { render, screen } from '@testing-library/react'; import App from '~/App';
import { renderWithProviders, screen } from '~/test-utils/test-helper';
test('hello', () => { test('should be able to render App', () => {
render(<div>hello</div>); renderWithProviders(<App />);
expect(screen.getByText('hello')).toBeInTheDocument();
// Quick sanity check of known strings.
expect(screen.getByText(/仅在浏览器内对文件进行解锁/i)).toBeInTheDocument();
expect(screen.getByText(/UnlockMusic 团队/i)).toBeInTheDocument();
}); });