-
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.
Merge pull request #35 from friendofdog/34-featured-content
Add method to get featured content by date
- Loading branch information
Showing
10 changed files
with
365 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
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); | ||
}); |
Oops, something went wrong.