Skip to content

Commit de6f580

Browse files
committed
[unit-testing] Added icon input theme config test cases
1 parent 03cf645 commit de6f580

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

src/packages/react-native-material-elements/__test__/V2ThemeContext.test.tsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
defaultLightTheme,
99
Divider,
1010
DividerColorThemeConfig,
11+
IconInput,
1112
Text,
1213
themeDimensions,
1314
ThemeProvider,
@@ -124,6 +125,36 @@ describe('V2ThemeContext', () => {
124125
});
125126

126127
describe('ThemeProvider component config', () => {
128+
const iconInputWrapperTestId = 'icon-input-test-id';
129+
130+
describe('iconInputProps', () => {
131+
it('should adopted theme inputWrapperStyles prop', () => {
132+
const { getByTestId } = themeRender(
133+
<ThemeProvider
134+
components={{ iconInputProps: { inputWrapperStyles: { width: 100, height: 100, backgroundColor: 'red' } } }}>
135+
<IconInput testID={iconInputWrapperTestId} />
136+
</ThemeProvider>,
137+
);
138+
139+
const inputWrapper = getByTestId(`${iconInputWrapperTestId}-wrapper`);
140+
const flattenStyles = StyleSheet.flatten(inputWrapper.props.style);
141+
expect(flattenStyles).toEqual(expect.objectContaining({ width: 100, height: 100, backgroundColor: 'red' }));
142+
});
143+
144+
it('should marge theme inputWrapperStyles prop and inputWrapperStyles component prop', () => {
145+
const { getByTestId } = themeRender(
146+
<ThemeProvider
147+
components={{ iconInputProps: { inputWrapperStyles: { width: 100, height: 100, backgroundColor: 'red' } } }}>
148+
<IconInput testID={iconInputWrapperTestId} inputWrapperStyles={{ width: 10, backgroundColor: 'green' }} />
149+
</ThemeProvider>,
150+
);
151+
152+
const inputWrapper = getByTestId(`${iconInputWrapperTestId}-wrapper`);
153+
const flattenStyles = StyleSheet.flatten(inputWrapper.props.style);
154+
expect(flattenStyles).toEqual(expect.objectContaining({ width: 10, backgroundColor: 'green' }));
155+
});
156+
});
157+
127158
describe('textProps', () => {
128159
const mockTextThemeConfig: TextVariationThemeConfig = {
129160
body1: { fontSize: 10, fontWeight: '100' },

0 commit comments

Comments
 (0)