Skip to content

Commit dd433b7

Browse files
authored
Merge pull request #1808 from smitbarmase/styled-test
[#1807] Added ThemeProvider for tests
2 parents db23e7a + db43b04 commit dd433b7

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

Diff for: client/test-utils.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
/**
22
* This file re-exports @testing-library but ensures that
3-
* any calls to render have translations available.
3+
* any calls to render have translations and theme available.
44
*
55
* This means tested components will be able to call
66
* `t()` and have the translations of the default
7-
* language
7+
* language also components will be able to call
8+
* `prop()` and have the theming of the default theme.
89
*
9-
* See: https://react.i18next.com/misc/testing#testing-without-stubbing
10+
* For i18n see: https://react.i18next.com/misc/testing#testing-without-stubbing
1011
*/
1112

1213
// eslint-disable-next-line import/no-extraneous-dependencies
@@ -15,15 +16,20 @@ import React from 'react';
1516
import PropTypes from 'prop-types';
1617

1718
import { I18nextProvider } from 'react-i18next';
19+
import { ThemeProvider } from 'styled-components';
20+
1821
import i18n from './i18n-test';
22+
import theme, { Theme } from './theme';
1923

2024
// re-export everything
2125
// eslint-disable-next-line import/no-extraneous-dependencies
2226
export * from '@testing-library/react';
2327

2428
const Providers = ({ children }) => (
2529
// eslint-disable-next-line react/jsx-filename-extension
26-
<I18nextProvider i18n={i18n}>{children}</I18nextProvider>
30+
<ThemeProvider theme={{ ...theme[Theme.light] }}>
31+
<I18nextProvider i18n={i18n}>{children}</I18nextProvider>
32+
</ThemeProvider>
2733
);
2834

2935
Providers.propTypes = {

0 commit comments

Comments
 (0)