Skip to content

refactor: component tree dead code #1403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 3, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 25 additions & 11 deletions src/__tests__/react-native-api.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { View, Text, TextInput } from 'react-native';
import { View, Text, TextInput, Switch } from 'react-native';
import { render } from '..';

/**
Expand All @@ -19,7 +19,6 @@ test('React Native API assumption: <View> renders single host element', () => {

test('React Native API assumption: <Text> renders single host element', () => {
const view = render(<Text testID="test">Hello</Text>);
expect(view.getByText('Hello')).toBe(view.getByTestId('test'));

expect(view.toJSON()).toMatchInlineSnapshot(`
<Text
Expand All @@ -40,11 +39,6 @@ test('React Native API assumption: nested <Text> renders single host element', (
</Text>
</Text>
);
expect(view.getByText(/Hello/)).toBe(view.getByTestId('test'));
expect(view.getByText('Before')).toBe(view.getByTestId('before'));
expect(view.getByText('Deeply nested')).toBe(
view.getByTestId('deeplyNested')
);

expect(view.toJSON()).toMatchInlineSnapshot(`
<Text
Expand Down Expand Up @@ -78,10 +72,6 @@ test('React Native API assumption: <TextInput> renders single host element', ()
placeholder="Placeholder"
/>
);
expect(view.getByPlaceholderText('Placeholder')).toBe(
view.getByTestId('test')
);

expect(view.toJSON()).toMatchInlineSnapshot(`
<TextInput
defaultValue="default"
Expand All @@ -91,3 +81,27 @@ test('React Native API assumption: <TextInput> renders single host element', ()
/>
`);
});

test('React Native API assumption: <Switch> renders single host element', () => {
const view = render(
<Switch testID="test" value={true} onChange={jest.fn()} />
);
expect(view.getByTestId('test')).toBe(view.getByTestId('test'));

expect(view.toJSON()).toMatchInlineSnapshot(`
<RCTSwitch
accessibilityRole="switch"
onChange={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
{
"height": 31,
"width": 51,
}
}
testID="test"
value={true}
/>
`);
});