mirror of
https://github.com/callstack/react-native-testing-library.git
synced 2026-09-18 23:09:04 +08:00
91200ef448
Co-authored-by: Michał Parkitny <michal.parkitny@callstack.com>
41 lines
1.0 KiB
JavaScript
41 lines
1.0 KiB
JavaScript
import * as React from 'react';
|
|
import { Provider } from 'react-redux';
|
|
import { fireEvent, render } from '@testing-library/react-native';
|
|
import configureStore from '../store';
|
|
import AddTodo from './AddTodo';
|
|
|
|
describe('Application test', () => {
|
|
test('adds a new test when entry has been included', () => {
|
|
const store = configureStore();
|
|
|
|
const component = (
|
|
<Provider store={store}>
|
|
<AddTodo />
|
|
</Provider>
|
|
);
|
|
|
|
const { getByPlaceholderText, getByText } = render(component);
|
|
|
|
const input = getByPlaceholderText(/repository/i);
|
|
expect(input).toBeTruthy();
|
|
|
|
const textToEnter = 'This is a random element';
|
|
fireEvent.changeText(input, textToEnter);
|
|
fireEvent.press(getByText('Submit form'));
|
|
|
|
const todosState = store.getState().todos;
|
|
|
|
expect(todosState.length).toEqual(1);
|
|
|
|
expect(todosState).toEqual(
|
|
expect.arrayContaining([
|
|
expect.objectContaining({
|
|
id: 1,
|
|
text: textToEnter,
|
|
date: expect.any(Date),
|
|
}),
|
|
])
|
|
);
|
|
});
|
|
});
|