-
Notifications
You must be signed in to change notification settings - Fork 2
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
2 changed files
with
61 additions
and
2 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,57 @@ | ||
import axios from 'axios' | ||
import React from 'react' | ||
import MockAdapter from 'axios-mock-adapter' | ||
import { render } from '@testing-library/react-native' | ||
import { setUserData } from '../../src/api/auth' | ||
import { ENDPOINTS as UNI_ENDPOINTS } from '../../src/api/universities' | ||
import { ENDPOINTS as OFFER_ENDPOINTS } from '../../src/api/offerings' | ||
import { format } from '../../src/utils/string' | ||
|
||
import { HTTP_STATUS_CODES } from '../../src/api' | ||
import { UNIVERSITY_RESPONSE } from '../mock_responses/mock-university-response' | ||
import Home from '../../src/containers/HomeContainer/Home' | ||
import { OFFERINGS_RESPONSE_1 } from '../mock_responses/mock-offerings-response' | ||
|
||
// const assertNoButtonsRendered = async () => { | ||
// const { queryAllByA11yRole } = render(<UniversityListContainer />) | ||
// const universityList = await waitFor(() => queryAllByA11yRole('button')) | ||
// expect(universityList.length).toBe(0) | ||
// } | ||
|
||
const mock = new MockAdapter(axios) | ||
describe('Check universities rendering', () => { | ||
const USER_DATA = { | ||
authToken: 'A', | ||
universityId: '1001', | ||
userId: 'test user', | ||
emaildId: '[email protected]', | ||
} | ||
|
||
const offeringId = 'ac5b1727-629c-443b-8c1a-cc1bd541af6a' | ||
|
||
afterEach(() => { | ||
mock.reset() | ||
}) | ||
|
||
test('Check that components render', async () => { | ||
const mockNavigator = { push: jest.fn() } | ||
|
||
mock.onGet(`${UNI_ENDPOINTS.UNIVERSITIES}`).reply(HTTP_STATUS_CODES.OK, UNIVERSITY_RESPONSE) | ||
mock | ||
.onGet(`${OFFER_ENDPOINTS.OFFERINGBYSTUDENT}`) | ||
.reply(HTTP_STATUS_CODES.OK, OFFERINGS_RESPONSE_1) | ||
mock | ||
.onGet(`${format(OFFER_ENDPOINTS.OFFERING, offeringId)}`) | ||
.reply(HTTP_STATUS_CODES.OK, OFFERINGS_RESPONSE_1) | ||
|
||
setUserData(USER_DATA) | ||
|
||
const { getByTestId } = render(<Home navigation={mockNavigator} />) | ||
|
||
const picker = await getByTestId('picker') | ||
expect(picker).not.toBe(null) | ||
|
||
const courseList = await getByTestId('courseList') | ||
expect(courseList).not.toBe(null) | ||
}) | ||
}) |
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