Skip to content

Commit d9a206e

Browse files
committed
refactor: code review changes
1 parent ce6efa1 commit d9a206e

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/__tests__/fire-event.test.tsx

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -140,17 +140,26 @@ test('fireEvent.scroll', () => {
140140

141141
test('fireEvent.changeText', () => {
142142
const onChangeTextMock = jest.fn();
143-
const CHANGE_TEXT = 'content';
144143

145144
render(
146145
<View>
147146
<TextInput placeholder="Customer placeholder" onChangeText={onChangeTextMock} />
148147
</View>,
149148
);
150149

151-
fireEvent.changeText(screen.getByPlaceholderText('Customer placeholder'), CHANGE_TEXT);
150+
const input = screen.getByPlaceholderText('Customer placeholder');
151+
fireEvent.changeText(input, 'content');
152+
expect(onChangeTextMock).toHaveBeenCalledWith('content');
153+
});
154+
155+
it('sets native state value for unmanaged text inputs', () => {
156+
render(<TextInput testID="input" />);
152157

153-
expect(onChangeTextMock).toHaveBeenCalledWith(CHANGE_TEXT);
158+
const input = screen.getByTestId('input');
159+
expect(input).toHaveDisplayValue('');
160+
161+
fireEvent.changeText(input, 'abc');
162+
expect(input).toHaveDisplayValue('abc');
154163
});
155164

156165
test('custom component with custom event name', () => {
@@ -444,14 +453,4 @@ describe('native events', () => {
444453
fireEvent(screen.getByTestId('test-id'), 'onMomentumScrollEnd');
445454
expect(onMomentumScrollEndSpy).toHaveBeenCalled();
446455
});
447-
448-
it('sets native state value for unmanaged text inputs', () => {
449-
render(<TextInput testID="input" />);
450-
451-
const input = screen.getByTestId('input');
452-
expect(input).toHaveDisplayValue('');
453-
454-
fireEvent.changeText(input, 'abc');
455-
expect(input).toHaveDisplayValue('abc');
456-
});
457456
});

0 commit comments

Comments
 (0)