Files
callstack__react-native-tes…/examples/redux/components/AddTodo.test.js
T
Michał 91200ef448 Updated React imports (#629)
Co-authored-by: Michał Parkitny <michal.parkitny@callstack.com>
2020-12-10 10:44:02 +01:00

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),
}),
])
);
});
});