1
1
import type { ViewStyle } from 'react-native' ;
2
2
3
- import { render , screen } from '@testing-library/react-native' ;
4
- import { MMKV } from 'react-native-mmkv' ;
3
+ import { render } from '@testing-library/react-native' ;
5
4
6
- import { ThemeProvider } from '@/theme ' ;
5
+ import TestAppWrapper from '@/../__mocks__/TestAppWrapper ' ;
7
6
8
7
import Brand from './Brand' ;
9
8
10
9
describe ( 'Brand component should render correctly' , ( ) => {
11
- let storage : MMKV ;
12
-
13
- beforeAll ( ( ) => {
14
- storage = new MMKV ( ) ;
15
- } ) ;
16
-
17
10
test ( 'with default props if not precises (height: 200, width: 200, resizeMode: "contain")' , ( ) => {
18
- const component = (
19
- < ThemeProvider storage = { storage } >
20
- < Brand />
21
- </ ThemeProvider >
22
- ) ;
23
-
24
- render ( component ) ;
11
+ const { getByTestId } = render ( < Brand /> , { wrapper : TestAppWrapper } ) ;
25
12
26
- const wrapper = screen . getByTestId ( 'brand-img-wrapper' ) ;
27
- const img = screen . getByTestId ( 'brand-img' ) ;
13
+ const wrapper = getByTestId ( 'brand-img-wrapper' ) ;
14
+ const img = getByTestId ( 'brand-img' ) ;
28
15
29
16
// Props set correctly
30
17
expect ( ( wrapper . props . style as ViewStyle ) . height ) . toBe ( 200 ) ;
@@ -33,16 +20,13 @@ describe('Brand component should render correctly', () => {
33
20
} ) ;
34
21
35
22
test ( 'with passed props' , ( ) => {
36
- const component = (
37
- < ThemeProvider storage = { storage } >
38
- < Brand height = { 100 } resizeMode = "cover" width = { 100 } />
39
- </ ThemeProvider >
23
+ const { getByTestId } = render (
24
+ < Brand height = { 100 } resizeMode = "cover" width = { 100 } /> ,
25
+ { wrapper : TestAppWrapper } ,
40
26
) ;
41
27
42
- render ( component ) ;
43
-
44
- const wrapper = screen . getByTestId ( 'brand-img-wrapper' ) ;
45
- const img = screen . getByTestId ( 'brand-img' ) ;
28
+ const wrapper = getByTestId ( 'brand-img-wrapper' ) ;
29
+ const img = getByTestId ( 'brand-img' ) ;
46
30
47
31
expect ( ( wrapper . props . style as ViewStyle ) . height ) . toBe ( 100 ) ;
48
32
expect ( ( wrapper . props . style as ViewStyle ) . width ) . toBe ( 100 ) ;
0 commit comments