-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
62 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* @jest-environment jsdom | ||
*/ | ||
|
||
import React from 'react'; | ||
import { render, waitFor } from '@testing-library/react'; | ||
import { InMemoryCache } from '@apollo/client'; | ||
import { MockedProvider } from '@apollo/client/testing'; | ||
import { BrowserRouter } from 'react-router-dom'; | ||
import '@testing-library/jest-dom/extend-expect'; | ||
|
||
import TestManagement from '../components/TestManagement'; | ||
|
||
// eslint-disable-next-line jest/no-mocks-import | ||
import { TEST_MANAGEMENT_PAGE_POPULATED } from './__mocks__/GraphQLMocks'; | ||
|
||
const setup = (mocks = []) => { | ||
return render( | ||
<BrowserRouter> | ||
<MockedProvider | ||
mocks={mocks} | ||
cache={new InMemoryCache({ addTypename: false })} | ||
> | ||
<TestManagement /> | ||
</MockedProvider> | ||
</BrowserRouter> | ||
); | ||
}; | ||
|
||
describe('Test Management page', () => { | ||
let wrapper; | ||
|
||
beforeEach(() => { | ||
wrapper = setup(TEST_MANAGEMENT_PAGE_POPULATED); | ||
}); | ||
|
||
it('renders loading state on initialization', async () => { | ||
const { getByTestId } = wrapper; | ||
const element = getByTestId('page-status'); | ||
|
||
expect(element).toBeTruthy(); | ||
expect(element).toHaveTextContent('Loading'); | ||
}); | ||
|
||
it('renders Status Summary component', async () => { | ||
// allow page time to load | ||
await waitFor(() => new Promise(res => setTimeout(res, 0))); | ||
|
||
const { queryAllByText } = wrapper; | ||
const statusSummaryElement = queryAllByText(/Status Summary/i); | ||
const testPlansElement = queryAllByText(/Test Plans/i); | ||
const phaseElement = queryAllByText(/Phase/i); | ||
const candidateElements = queryAllByText(/Candidate/i); | ||
const notTestedElements = queryAllByText(/Not tested/i); | ||
|
||
expect(statusSummaryElement.length).toBeGreaterThanOrEqual(1); | ||
expect(testPlansElement.length).toBeGreaterThanOrEqual(1); | ||
expect(phaseElement.length).toBeGreaterThanOrEqual(1); | ||
expect(candidateElements.length).toBeGreaterThanOrEqual(1); | ||
expect(notTestedElements.length).toBeGreaterThanOrEqual(1); | ||
}); | ||
}); |