-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(React): Home page tests (#2184)
Co-authored-by: John Joyce <john@acryl.io>
- Loading branch information
1 parent
2e8a0ce
commit 3537b2e
Showing
4 changed files
with
58 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
datahub-web-react/src/app/home/__tests__/HomePage.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React from 'react'; | ||
import { render, waitFor, fireEvent } from '@testing-library/react'; | ||
import { MockedProvider } from '@apollo/client/testing'; | ||
import { HomePage } from '../HomePage'; | ||
import { mocks } from '../../../Mocks'; | ||
import TestPageContainer from '../../../utils/test-utils/TestPageContainer'; | ||
|
||
describe('HomePage', () => { | ||
it('renders', () => { | ||
render( | ||
<MockedProvider mocks={mocks} addTypename={false}> | ||
<TestPageContainer> | ||
<HomePage /> | ||
</TestPageContainer> | ||
</MockedProvider>, | ||
); | ||
}); | ||
|
||
it('renders greeting message', async () => { | ||
const { getByText } = render( | ||
<MockedProvider mocks={mocks} addTypename={false}> | ||
<TestPageContainer> | ||
<HomePage /> | ||
</TestPageContainer> | ||
</MockedProvider>, | ||
); | ||
await waitFor(() => expect(getByText('Welcome back, .')).toBeInTheDocument()); | ||
}); | ||
|
||
it('renders browsable entities', async () => { | ||
const { getByText } = render( | ||
<MockedProvider mocks={mocks} addTypename={false}> | ||
<TestPageContainer> | ||
<HomePage /> | ||
</TestPageContainer> | ||
</MockedProvider>, | ||
); | ||
await waitFor(() => expect(getByText('Datasets')).toBeInTheDocument()); | ||
}); | ||
|
||
it('renders autocomplete results', async () => { | ||
const { getByTestId, queryByTitle } = render( | ||
<MockedProvider mocks={mocks} addTypename={false}> | ||
<TestPageContainer> | ||
<HomePage /> | ||
</TestPageContainer> | ||
</MockedProvider>, | ||
); | ||
const searchInput = getByTestId('search-input'); | ||
fireEvent.change(searchInput, { target: { value: 't' } }); | ||
|
||
await waitFor(() => expect(queryByTitle('The Great Test Dataset')).toBeInTheDocument()); | ||
await waitFor(() => expect(queryByTitle('Some other test')).toBeInTheDocument()); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters