Skip to content

Commit 4eaafab

Browse files
authored
fix: check and fixed failing tests (#1673)
1 parent e591303 commit 4eaafab

File tree

6 files changed

+17
-34
lines changed

6 files changed

+17
-34
lines changed

src/components/devsupport/components/falsyFC/falsyFC.spec.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@ it('should render provided function component', () => {
3030

3131
it('should render provided function component with hooks', () => {
3232
const HookComponent = (props): React.ReactElement => {
33-
const state = React.useState(1);
33+
const [state] = React.useState(1);
3434
return (
3535
<Text {...props}>
36-
I love Babel
37-
{state}
36+
{`I love Babel ${state}`}
3837
</Text>
3938
);
4039
};

src/components/devsupport/components/falsyText/falsyText.spec.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,10 @@ it('should render provided function component', () => {
3535

3636
it('should render provided function component with hooks', () => {
3737
const HookComponent = (props): React.ReactElement => {
38-
const state = React.useState(1);
38+
const [state] = React.useState(1);
3939
return (
4040
<Text {...props}>
41-
I love Babel
42-
{state}
41+
{`I love Babel ${state}`}
4342
</Text>
4443
);
4544
};

src/components/ui/calendar/calendar.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('@calendar: component checks', () => {
3333
* Get rid of useNativeDriver warnings
3434
*/
3535
beforeAll(() => {
36-
jest.mock('react-native/Libraries/Animated/src/NativeAnimatedHelper');
36+
jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper');
3737
});
3838

3939
afterAll(() => {

src/components/ui/calendar/rangeCalendar.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('@range-calendar: component checks', () => {
2525
* Get rid of useNativeDriver warnings
2626
*/
2727
beforeAll(() => {
28-
jest.mock('react-native/Libraries/Animated/src/NativeAnimatedHelper');
28+
jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper');
2929
});
3030

3131
afterAll(() => {

src/components/ui/shared/tabIndicator.component.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
View,
1515
ViewProps,
1616
ViewStyle,
17+
StyleSheet,
1718
} from 'react-native';
1819
import { RTLService } from '../../devsupport';
1920

@@ -99,7 +100,7 @@ export class TabIndicator extends React.Component<TabIndicatorProps> {
99100
};
100101

101102
private renderIndicatorLine = (style: StyleProp<ViewStyle>): React.ReactElement => {
102-
const styles = [{ width: '100%', alignSelf: 'center', style }] as StyleProp<ViewStyle>;
103+
const styles = [{ width: '100%', alignSelf: 'center' }, StyleSheet.flatten(style)] as StyleProp<ViewStyle>;
103104
return (
104105
<View
105106
testID="indicator body"

src/components/ui/tab/tab.spec.tsx

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import React from 'react';
88
import {
99
Image,
10-
ImageProps,
10+
ImageProps, StyleSheet,
1111
Text,
1212
TouchableOpacity,
1313
} from 'react-native';
@@ -175,19 +175,11 @@ describe('@tab-bar: component checks', () => {
175175
<TestTabBar indicatorStyle={styles} />,
176176
);
177177

178-
const el = ((
179-
(component.UNSAFE_queryByType(TabIndicator).children[0] as ReactTestInstance)
180-
.children[0] as ReactTestInstance)
181-
.children[0] as ReactTestInstance)
182-
.children[0] as ReactTestInstance;
178+
const el = component.queryByTestId('indicator body');
179+
const style = StyleSheet.flatten(el.props.style);
183180

184-
// default styles
185-
expect(el.props.style[0].width).toEqual('100%');
186-
expect(el.props.style[1][0].backgroundColor).toEqual('#3366FF');
187-
188-
// custom styles
189-
expect(el.props.style[1][1].width).toEqual(99);
190-
expect(el.props.style[1][1].backgroundColor).toEqual('red');
181+
expect(style.width).toEqual(99);
182+
expect(style.backgroundColor).toEqual('red');
191183
});
192184
});
193185

@@ -245,19 +237,11 @@ describe('@tab-view: component checks', () => {
245237
<TestTabView indicatorStyle={styles} />,
246238
);
247239

248-
const el = ((
249-
(component.UNSAFE_queryByType(TabIndicator).children[0] as ReactTestInstance)
250-
.children[0] as ReactTestInstance)
251-
.children[0] as ReactTestInstance)
252-
.children[0] as ReactTestInstance;
253-
254-
// default styles
255-
expect(el.props.style[0].width).toEqual('100%');
256-
expect(el.props.style[1][0].backgroundColor).toEqual('#3366FF');
240+
const el = component.queryByTestId('indicator body');
241+
const style = StyleSheet.flatten(el.props.style);
257242

258-
// custom styles
259-
expect(el.props.style[1][1].width).toEqual(99);
260-
expect(el.props.style[1][1].backgroundColor).toEqual('red');
243+
expect(style.width).toEqual(99);
244+
expect(style.backgroundColor).toEqual('red');
261245
});
262246
});
263247

0 commit comments

Comments
 (0)