-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add method to get featured content by date
resolves #34
- Loading branch information
1 parent
0529be1
commit 585d4f0
Showing
7 changed files
with
272 additions
and
4 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
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,39 @@ | ||
import { fcError } from '../source/errors'; | ||
import * as request from '../source/request'; | ||
import wiki from "../source/index"; | ||
import { fcData } from './samples'; | ||
const requestMock = jest.spyOn(request, "makeRestRequest"); | ||
|
||
const fcMock = fcData; | ||
|
||
afterAll(() => { | ||
requestMock.mockRestore(); | ||
}) | ||
|
||
test('Throws featured content error if response is error', async () => { | ||
requestMock.mockImplementation(async () => { throw new Error("This is an error") }); | ||
const result = async () => { | ||
await wiki.featuredContent({}) | ||
}; | ||
expect(result).rejects.toThrowError(fcError); | ||
}); | ||
|
||
test('Returns with results as fcResult', async () => { | ||
requestMock.mockImplementation(async () => { return fcMock }); | ||
const result = await wiki.featuredContent(); | ||
expect(result).toStrictEqual(fcMock); | ||
}); | ||
|
||
test('Featured content method call with params passed and no padding', async () => { | ||
requestMock.mockImplementation(async () => { return fcMock }); | ||
const result = await wiki.featuredContent({ year: '2020', month: '1', day: '1' }); | ||
expect(result).toStrictEqual(fcMock); | ||
expect(requestMock).toBeCalledWith(`feed/featured/2020/01/01`, true); | ||
}); | ||
|
||
test('Featured content method call with params passed', async () => { | ||
requestMock.mockImplementation(async () => { return fcMock }); | ||
const result = await wiki.featuredContent({ year: '2020', month: '01', day: '01' }); | ||
expect(result).toStrictEqual(fcMock); | ||
expect(requestMock).toBeCalledWith(`feed/featured/2020/01/01`, true); | ||
}); |
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