Skip to content

Commit 18a4048

Browse files
committed
simple tests complete
dropdown selection turns out to be a massive pain to test, so I didn't (hoaphantn7604/react-native-element-dropdown#175)
1 parent cbf3eb1 commit 18a4048

File tree

1 file changed

+12
-33
lines changed

1 file changed

+12
-33
lines changed
Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import { render, fireEvent, waitFor } from '@testing-library/react-native';
33
import CreateTaskScreen from '../app/screens/CreateTaskScreen';
4+
import { addEvent } from '../app/scripts/database';
45

56
jest.mock('../app/scripts/database', () => ({
67
addEvent: jest.fn(),
@@ -25,43 +26,21 @@ describe('CreateTaskScreen', () => {
2526
expect(titleInput.props.value).toBe('New Task Title');
2627
});
2728

28-
it('handles date pickers correctly', async () => {
29+
it('calls addEvent on save', async () => {
2930
const { getByTestId, getByText } = render(<CreateTaskScreen />);
30-
const startDateButton = getByTestId('Start Date');
3131

32-
fireEvent.press(startDateButton);
32+
fireEvent.changeText(getByTestId('Title'), 'Test Event');
33+
fireEvent.changeText(getByTestId('Description'), 'Test Description');
34+
fireEvent.press(getByText('Save Task'));
3335

34-
// Assume DateTimePicker becomes visible
3536
await waitFor(() => {
36-
expect(getByText('OK')).toBeTruthy();
37+
expect(addEvent).toHaveBeenCalledWith(
38+
'Test Event',
39+
'Test Description',
40+
expect.any(String),
41+
expect.any(String),
42+
''
43+
);
3744
});
3845
});
39-
40-
// it('handles dropdown selection', () => {
41-
// const { getByText } = render(<CreateTaskScreen />);
42-
// const dropdown = getByText('Select item');
43-
44-
// fireEvent.press(dropdown);
45-
// fireEvent.press(getByText('Walk'));
46-
47-
// expect(getByText('Walk')).toBeTruthy();
48-
// });
49-
50-
// it('calls addEvent on save', async () => {
51-
// const { getByPlaceholderText, getByText } = render(<CreateTaskScreen />);
52-
53-
// fireEvent.changeText(getByPlaceholderText('Title'), 'Test Event');
54-
// fireEvent.changeText(getByPlaceholderText('Task / event description here'), 'Test Description');
55-
// fireEvent.press(getByText('Save Task'));
56-
57-
// await waitFor(() => {
58-
// expect(addEvent).toHaveBeenCalledWith(
59-
// 'Test Event',
60-
// 'Test Description',
61-
// expect.any(String),
62-
// expect.any(String),
63-
// ''
64-
// );
65-
// });
66-
// });
6746
});

0 commit comments

Comments
 (0)