forked from bamlab/react-native-testing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTodoList.test.tsx
More file actions
29 lines (27 loc) · 1020 Bytes
/
TodoList.test.tsx
File metadata and controls
29 lines (27 loc) · 1020 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import React from 'react';
import { renderPage, getPropsWithNavigation } from '../../../utils/tests/helpers';
import { TodoList } from '../TodoList';
import { wording } from '../../../utils/wording';
import { fireEvent, waitForElement } from 'react-native-testing-library';
describe('[Page] TodoList', () => {
const initialState = {
todos: {
todoList: ['buy groceries'],
},
};
it('should display previous and new todos', async () => {
const newTodoText = 'go running';
const page = renderPage(<TodoList />, initialState);
// GIVEN
const TodoInput = page.getByPlaceholder(wording.todos.newTodo);
const AddTodoButton = page.getByText(wording.todos.add);
const FirstTodo = page.queryByText('buy groceries');
expect(FirstTodo).toBeTruthy();
// WHEN
fireEvent.changeText(TodoInput, newTodoText);
fireEvent.press(AddTodoButton);
// THEN
const NewTodo = await waitForElement(() => page.queryByText(newTodoText));
expect(NewTodo).toBeTruthy();
});
});