Skip to content

Commit

Permalink
updated test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
akanshaaaa19 committed Jan 12, 2024
1 parent 34aaae8 commit 630552b
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/containers/SettingList/Organisation/Organisation.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,26 @@ test('it renders component in edit mode', async () => {
</Router>
</MockedProvider>
);
// loading is show initially
// loading is show initially
expect(getByText('Loading...')).toBeInTheDocument();

//correct values are rendered in the form
await waitFor(() => {
const phoneNumber = getByTestId('phoneNumber');
const inputElements = screen.getAllByRole('textbox');
const numberInputElements = screen.getAllByRole('spinbutton');

const orgName = inputElements[0] as unknown as HTMLInputElement;
const signaturePhrase = inputElements[1] as unknown as HTMLInputElement;
const phoneNumber = inputElements[2] as unknown as HTMLInputElement;
const lowBalanceThreshold = numberInputElements[0] as unknown as HTMLInputElement;
const criticalBalanceThreshold = numberInputElements[1] as unknown as HTMLInputElement;

fireEvent.click(phoneNumber);
expect(phoneNumber).toBeInTheDocument();
expect(orgName?.value).toBe('Glific');
expect(signaturePhrase?.value).toBe('Please change me, NOW!');
expect(phoneNumber?.value).toBe('917834811114');
expect(lowBalanceThreshold?.value).toBe('10');
expect(criticalBalanceThreshold?.value).toBe('5');
});

await waitFor(() => {
Expand All @@ -80,15 +93,15 @@ test('it renders component in edit mode', async () => {
});

test('it submits form correctly', async () => {
const { getByText, getByTestId } = render(wrapper);
const { getByText } = render(wrapper);

expect(getByText('Loading...')).toBeInTheDocument();

await waitFor(() => {
const inputElements = screen.getAllByRole('textbox');
const numberInputElements = screen.getAllByRole('spinbutton');

fireEvent.change(inputElements[0], { target: { value: 'Glificc' } });
fireEvent.change(inputElements[0], { target: { value: 'Glific' } });
fireEvent.change(inputElements[1], { target: { value: 'Please change me, NOW!' } });
fireEvent.change(numberInputElements[0], { target: { value: '10' } });
fireEvent.change(numberInputElements[1], { target: { value: '5' } });
Expand All @@ -99,8 +112,4 @@ test('it submits form correctly', async () => {
expect(submitButton).toBeInTheDocument();
fireEvent.click(submitButton);
});

await waitFor(() => {
expect(getByTestId('formLayout')).toHaveTextContent('Organisation name');
});
});

0 comments on commit 630552b

Please sign in to comment.