Created
December 10, 2020 19:01
-
-
Save aloverso/b0541d69f6cabc5d31c5d56ca514a968 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import externalApiFixtureData from "./onetTestDataTasks.json"; | |
| import {getUserDetailsForId} from "./apiClient.ts"; | |
| jest.mock("axios"); | |
| const mockedAxios = axios as jest.Mocked<typeof axios>; | |
| describe("my cool external API integration", () => { | |
| it("returns description when tasks and related occupations fail", async () => { | |
| mockedAxios.get.mockResolvedValue({data: externalApiFixtureData}) | |
| const userDetails = await getUserDetailsForId("172051"); | |
| expect(mockedAxios.get).toHaveBeenCalledWith( | |
| "wwww.some-api-url.com/webservices/online/userdetails/172051" | |
| ) | |
| expect(userDetails).toEqual({ | |
| id: "172051", | |
| name: "Firstname Lastname", | |
| title: "Civil Engineer", | |
| description: "Performs engineering duties in planning and designing building structures", | |
| projects: [ | |
| { | |
| id: "1234", | |
| name: "Roadway Design" | |
| }, | |
| { | |
| id: "5678", | |
| name: "Airport Structural Maintenance" | |
| } | |
| ] | |
| }); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment