This repository has been archived by the owner on Jun 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(refactor): add referee services tests (#94)
- Loading branch information
1 parent
b8c90f2
commit 23d5dfe
Showing
24 changed files
with
442 additions
and
66 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "client", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "The client lib for the Referee UX", | ||
"author": "Justin Field <[email protected]>", | ||
"homepage": "https://example.com/dashboard/", | ||
|
@@ -70,6 +70,7 @@ | |
"@types/react-syntax-highlighter": "^13.5.0", | ||
"@types/uuid": "^8.3.0", | ||
"@types/yup": "^0.26.12", | ||
"axios-mock-adapter": "^1.19.0", | ||
"node-sass": "^4.12.0" | ||
}, | ||
"repository": { | ||
|
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
1 change: 0 additions & 1 deletion
1
packages/client/src/components/shared/IndividualMetricView.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
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
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 was deleted.
Oops, something went wrong.
41 changes: 41 additions & 0 deletions
41
packages/client/src/services/__tests__/DocsService.test.ts
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,41 @@ | ||
import MockAdapter from 'axios-mock-adapter'; | ||
import axios from 'axios'; | ||
import DocsService from '../DocsService'; | ||
|
||
describe('DocsService', () => { | ||
let httpMock; | ||
let docsService; | ||
|
||
beforeEach(() => { | ||
httpMock = new MockAdapter(axios); | ||
docsService = new DocsService(); | ||
}); | ||
|
||
it('should fetch toc', async () => { | ||
const expectedData = { response: true }; | ||
httpMock.onGet(`${process.env.PUBLIC_URL}/docs/table-of-contents.yaml`).reply(200, expectedData); | ||
const actualData = await docsService.fetchToc(); | ||
expect(actualData).toEqual(expectedData); | ||
}); | ||
|
||
it('should not fetch toc and throw error', async () => { | ||
const expectedData = { response: true }; | ||
httpMock.onGet(`${process.env.PUBLIC_URL}/docs/table-of-contents.yaml`).reply(404, expectedData); | ||
await expect(docsService.fetchToc()).rejects.toThrowError(/Request failed with status code 404/); | ||
}); | ||
|
||
it('should fetch doc content', async () => { | ||
const markdown = 'markdown'; | ||
const expectedData = { response: true }; | ||
httpMock.onGet(`${process.env.PUBLIC_URL}/docs/${markdown}`).reply(200, expectedData); | ||
const actualData = await docsService.fetchDocContent(markdown); | ||
expect(actualData).toEqual(expectedData); | ||
}); | ||
|
||
it('should not fetch doc content and throw error', async () => { | ||
const markdown = 'markdown'; | ||
const expectedData = { response: true }; | ||
httpMock.onGet(`${process.env.PUBLIC_URL}/docs/${markdown}`).reply(404, expectedData); | ||
await expect(docsService.fetchDocContent(markdown)).rejects.toThrowError(/Request failed with status code 404/); | ||
}); | ||
}); |
40 changes: 40 additions & 0 deletions
40
packages/client/src/services/__tests__/FetchCanaryResultsService.test.ts
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,40 @@ | ||
import MockAdapter from 'axios-mock-adapter'; | ||
import { kayentaClient } from '../KayentaApiService'; | ||
import { fetchCanaryResultsService } from '../index'; | ||
|
||
describe('FetchCanaryResultsService', () => { | ||
let httpMock; | ||
|
||
beforeEach(() => { | ||
httpMock = new MockAdapter(kayentaClient); | ||
}); | ||
|
||
afterEach(() => { | ||
httpMock.restore(); | ||
}); | ||
|
||
it('should poll for response successfully', async () => { | ||
const expectedData = { | ||
complete: true, | ||
config: 'test' | ||
}; | ||
|
||
const url = new RegExp(`/canary/*`); | ||
httpMock.onGet(url).reply(200, expectedData); | ||
const actualData = await fetchCanaryResultsService.pollForResponse(); | ||
expect(actualData).toEqual(expectedData); | ||
}); | ||
|
||
it('should poll for response unsuccessfully', function(done) { | ||
const data = { | ||
complete: false, | ||
config: 'test' | ||
}; | ||
|
||
const url = new RegExp(`/canary/*`); | ||
httpMock.onGet(url).reply(200, data); | ||
const actualData = fetchCanaryResultsService.pollForResponse(); | ||
expect(actualData).resolves.toEqual({}); | ||
done(); | ||
}); | ||
}); |
Oops, something went wrong.