|
|
@ -1,5 +1,5 @@ |
|
|
|
import React from 'react'; |
|
|
|
import { fireEvent } from '@testing-library/react'; |
|
|
|
import { fireEvent, waitForElement } from '@testing-library/react'; |
|
|
|
import { getNetwork, injections, renderWithProviders } from 'utils/tests'; |
|
|
|
import Home from './Home'; |
|
|
|
|
|
|
@ -24,30 +24,35 @@ describe('Home component', () => { |
|
|
|
expect(await findByText('error reading file')).toBeInTheDocument(); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should display a list of networks', () => { |
|
|
|
it('should display a list of networks', async () => { |
|
|
|
const { getByText } = renderComponent(); |
|
|
|
await waitForElement(() => getByText('Click Me!')); |
|
|
|
expect(getByText('my network 1')).toBeInTheDocument(); |
|
|
|
expect(getByText('my network 2')).toBeInTheDocument(); |
|
|
|
expect(getByText('my network 3')).toBeInTheDocument(); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should contain a "Click Me!" button', () => { |
|
|
|
it('should contain a "Click Me!" button', async () => { |
|
|
|
const { getByText } = renderComponent(); |
|
|
|
await waitForElement(() => getByText('Click Me!')); |
|
|
|
expect(getByText('Click Me!')).toBeInTheDocument(); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should contain a link to Counter page', () => { |
|
|
|
it('should contain a link to Counter page', async () => { |
|
|
|
const { getByText } = renderComponent(); |
|
|
|
await waitForElement(() => getByText('Click Me!')); |
|
|
|
expect(getByText('Network')).toBeInTheDocument(); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should not show alert message', () => { |
|
|
|
const { queryByTestId } = renderComponent(); |
|
|
|
expect(queryByTestId('success')).toBeFalsy(); |
|
|
|
it('should not show alert message', async () => { |
|
|
|
const { queryByText, getByText } = renderComponent(); |
|
|
|
await waitForElement(() => getByText('Click Me!')); |
|
|
|
expect(queryByText('Success Tips')).toBeNull(); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should show alert after button is clicked', () => { |
|
|
|
it('should show alert after button is clicked', async () => { |
|
|
|
const { getByText } = renderComponent(); |
|
|
|
await waitForElement(() => getByText('Click Me!')); |
|
|
|
const btn = getByText('Click Me!'); |
|
|
|
fireEvent.click(btn); |
|
|
|
expect(getByText('Success Tips')).toBeInTheDocument(); |
|
|
|