2021-02-14 07:37:22 +03:00
|
|
|
import { h } from 'preact';
|
|
|
|
|
import * as IDB from 'idb-keyval';
|
|
|
|
|
import * as PreactRouter from 'preact-router';
|
|
|
|
|
import App from '../App';
|
2022-03-06 07:16:31 +03:00
|
|
|
import { render, screen } from 'testing-library';
|
2021-02-14 07:37:22 +03:00
|
|
|
|
|
|
|
|
describe('App', () => {
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
jest.spyOn(IDB, 'get').mockImplementation(() => Promise.resolve(undefined));
|
|
|
|
|
jest.spyOn(IDB, 'set').mockImplementation(() => Promise.resolve(true));
|
|
|
|
|
jest.spyOn(PreactRouter, 'Router').mockImplementation(() => <div data-testid="router" />);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('shows a loading indicator while loading', async () => {
|
|
|
|
|
render(<App />);
|
|
|
|
|
await screen.findByTestId('app');
|
|
|
|
|
expect(screen.queryByLabelText('Loading…')).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
});
|