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">
<FileListing />
</Box>
{localStorage.__dev_test === '1' && <WasmTest />}
<WasmTest />
<Footer />
</Container>
</Box>

View File

@ -1,5 +1,6 @@
import { loadLibParakeet, BlobSink, createArrayBufferReader } from '@jixun/libparakeet';
/* c8 ignore start: test only code */
function testWasm() {
loadLibParakeet().then(async (mod) => {
const data = new Uint8Array(0x2000);
@ -23,9 +24,15 @@ function testWasm() {
}
export function WasmTest() {
// Some secret test flags...
if (localStorage.__dev_test !== '1') {
return null;
}
return (
<button onClick={testWasm} type="button">
Test WASM
</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', () => {
render(<div>hello</div>);
expect(screen.getByText('hello')).toBeInTheDocument();
test('should be able to render App', () => {
renderWithProviders(<App />);
// Quick sanity check of known strings.
expect(screen.getByText(/仅在浏览器内对文件进行解锁/i)).toBeInTheDocument();
expect(screen.getByText(/UnlockMusic 团队/i)).toBeInTheDocument();
});