Skip to content

Commit

Permalink
added edge case tests with invalid number input and 0
Browse files Browse the repository at this point in the history
  • Loading branch information
Raboro committed Sep 21, 2023
1 parent 13eedef commit c7461dd
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,24 @@ describe('App', () => {
rend.getByTestId('PaymentHistory').props.children[4].props.data[0],
).toMatchObject({ id: '0', value: 100 });
});

test('try to add invalid Payment', async () => {
const rend = await waitFor(() => render(<App />));
fireEvent(rend.getByTestId('FooterTouchable'), 'press');
const inputElement = rend.getByPlaceholderText('Payment');
fireEvent.changeText(inputElement, 'aaaa');
await waitFor(() => fireEvent(rend.getByText('Submit'), 'press'));
fireEvent(rend.getByText('List of Payments'), 'press');
expect(rend.getByTestId('PaymentHistory').props.children[4].props.data.length).toBe(0)
});

test('try to add zero Payment', async () => {
const rend = await waitFor(() => render(<App />));
fireEvent(rend.getByTestId('FooterTouchable'), 'press');
const inputElement = rend.getByPlaceholderText('Payment');
fireEvent.changeText(inputElement, '0');
await waitFor(() => fireEvent(rend.getByText('Submit'), 'press'));
fireEvent(rend.getByText('List of Payments'), 'press');
expect(rend.getByTestId('PaymentHistory').props.children[4].props.data.length).toBe(0)
});
});

0 comments on commit c7461dd

Please sign in to comment.