mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 17:45:22 +00:00
test: add testRender()
This adds a testRender() helper function to simplify UI tests. Instead of mocking the redux store, we use the real thing.
This commit is contained in:
+3
-20
@@ -1,27 +1,10 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2021 The Pybricks Authors
|
||||
// Copyright (c) 2021-2022 The Pybricks Authors
|
||||
|
||||
import { I18nContext, I18nManager } from '@shopify/react-i18n';
|
||||
import { render } from '@testing-library/react';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import React from 'react';
|
||||
import { Provider } from 'react-redux';
|
||||
import { Store } from 'redux';
|
||||
import { RootState } from '../reducers';
|
||||
import { testRender } from '../../test';
|
||||
import App from './App';
|
||||
|
||||
it.each([false, true])('should render', (darkMode) => {
|
||||
const store = mock<Store<RootState>>({
|
||||
getState: () => mock<RootState>({ settings: { darkMode } }),
|
||||
});
|
||||
|
||||
const i18n = new I18nManager({ locale: 'en' });
|
||||
|
||||
render(
|
||||
<Provider store={store}>
|
||||
<I18nContext.Provider value={i18n}>
|
||||
<App />
|
||||
</I18nContext.Provider>
|
||||
</Provider>,
|
||||
);
|
||||
testRender(<App />, { settings: { darkMode } });
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user