11import type { ViewStyle } from 'react-native' ;
22
3- import { render , screen } from '@testing-library/react-native' ;
4- import { MMKV } from 'react-native-mmkv' ;
3+ import { render } from '@testing-library/react-native' ;
54
6- import { ThemeProvider } from '@/theme ' ;
5+ import TestAppWrapper from '@/../__mocks__/TestAppWrapper ' ;
76
87import Brand from './Brand' ;
98
109describe ( 'Brand component should render correctly' , ( ) => {
11- let storage : MMKV ;
12-
13- beforeAll ( ( ) => {
14- storage = new MMKV ( ) ;
15- } ) ;
16-
1710 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 } ) ;
2512
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' ) ;
2815
2916 // Props set correctly
3017 expect ( ( wrapper . props . style as ViewStyle ) . height ) . toBe ( 200 ) ;
@@ -33,16 +20,13 @@ describe('Brand component should render correctly', () => {
3320 } ) ;
3421
3522 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 } ,
4026 ) ;
4127
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' ) ;
4630
4731 expect ( ( wrapper . props . style as ViewStyle ) . height ) . toBe ( 100 ) ;
4832 expect ( ( wrapper . props . style as ViewStyle ) . width ) . toBe ( 100 ) ;
0 commit comments