-
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.
Merge pull request #25 from CS428-CT/fix-offerings
Fix offerings
- Loading branch information
Showing
14 changed files
with
344 additions
and
159 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
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
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
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,37 @@ | ||
import axios from 'axios' | ||
import { HTTP_STATUS_CODES } from '.' | ||
import { API_BASE_URL } from '../constants' | ||
import { format } from '../utils/string' | ||
|
||
export const ENDPOINTS = { | ||
TRANSCRIPT: `${API_BASE_URL}Captions/ByTranscription/{0}`, | ||
MEDIA: `${API_BASE_URL}Media/{0}`, | ||
} | ||
|
||
export const getVideoTranscription = async (transcriptionId) => { | ||
const url = format(ENDPOINTS.TRANSCRIPT, transcriptionId) | ||
|
||
try { | ||
const resp = await axios.get(url) | ||
if (resp?.status !== HTTP_STATUS_CODES.OK) return null | ||
return resp.data | ||
} catch (error) { | ||
console.error(error) | ||
} | ||
|
||
return null | ||
} | ||
|
||
export const getMedia = async (mediaId) => { | ||
const url = format(ENDPOINTS.MEDIA, mediaId.mediaId) | ||
|
||
try { | ||
const resp = await axios.get(url) | ||
if (resp?.status !== HTTP_STATUS_CODES.OK) return null | ||
return resp.data | ||
} catch (error) { | ||
console.error(error) | ||
} | ||
|
||
return 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
Oops, something went wrong.