@@ -4,28 +4,42 @@ import * as UITest from 'react-native-testing-library';
4
4
import { ThemeProvider , withTheme , WithThemeProps } from './index' ;
5
5
6
6
interface TestProps extends WithThemeProps {
7
- name : string ;
7
+ testId : string ;
8
8
}
9
9
10
10
class TestComponent extends React . Component < TestProps > {
11
11
render ( ) {
12
- const { theme, name} = this . props ;
13
-
12
+ console . info ( `TestComponent theme prop: ${ JSON . stringify ( this . props . theme ) } ` ) ;
14
13
return (
15
- < View />
14
+ < View testID = { this . props . testId } />
16
15
) ;
17
16
}
18
17
}
19
18
20
- it ( 'Checks simple Provider/Consumer theme pass ' , async ( ) => {
19
+ it ( 'Checks theme consumer renders properly ' , async ( ) => {
21
20
const ThemedComponent = withTheme ( TestComponent ) ;
21
+ const themedComponentTestId = '@theme/root' ;
22
22
23
23
const component = UITest . render (
24
- < ThemeProvider >
25
- < ThemedComponent name = { 'test' } />
24
+ < ThemeProvider theme = { { } } >
25
+ < ThemedComponent testId = { themedComponentTestId } />
26
26
</ ThemeProvider > ,
27
27
) ;
28
28
29
- // TODO: finish test
29
+ const themedComponent = component . getByTestId ( themedComponentTestId ) ;
30
+ expect ( themedComponent ) . not . toBeNull ( ) ;
30
31
} ) ;
31
32
33
+ it ( 'Checks theme consumer receives theme prop' , async ( ) => {
34
+ const ThemedComponent = withTheme ( TestComponent ) ;
35
+ const themedComponentTestId = '@theme/root' ;
36
+
37
+ const component = UITest . render (
38
+ < ThemeProvider theme = { { } } >
39
+ < ThemedComponent testId = { themedComponentTestId } />
40
+ </ ThemeProvider > ,
41
+ ) ;
42
+
43
+ const themedComponent = component . getByTestId ( themedComponentTestId ) ;
44
+ expect ( themedComponent . props . theme ) . not . toBeNull ( ) ;
45
+ } ) ;
0 commit comments