-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
cglotr
committed
Jun 20, 2023
1 parent
21b8113
commit 6b1b061
Showing
3 changed files
with
156 additions
and
9 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,66 @@ | ||
import { FavApiImpl } from "../../src/apis/fav_api_impl" | ||
import { server } from '../../mocks/server' | ||
|
||
describe('FavApiImpl', () => { | ||
beforeAll(() => server.listen()) | ||
|
||
afterEach(() => server.resetHandlers()) | ||
|
||
afterAll(() => server.close()) | ||
|
||
describe('valid token', () => { | ||
const favApiImpl = new FavApiImpl('valid_token') | ||
|
||
test('add', async () => { | ||
const actual = await favApiImpl.add(1, 1) | ||
const expected = [ | ||
{ | ||
id: 1, | ||
surah: 1, | ||
verse: 1 | ||
} | ||
] | ||
expect(actual).toEqual(expected) | ||
}) | ||
|
||
test('remove', async () => { | ||
const actual = await favApiImpl.remove(1) | ||
expect(actual).toEqual([]) | ||
}) | ||
|
||
test('list', async () => { | ||
const actual = await favApiImpl.list() | ||
expect(actual).toEqual([ | ||
{ | ||
id: 1, | ||
surah: 1, | ||
verse: 1 | ||
}, | ||
{ | ||
id: 2, | ||
surah: 1, | ||
verse: 2 | ||
} | ||
]) | ||
}) | ||
}) | ||
|
||
describe('invalid token', () => { | ||
const favApiImpl = new FavApiImpl('invalid_token') | ||
|
||
test('add', async () => { | ||
const actual = await favApiImpl.add(1, 1) | ||
expect(actual).toEqual([]) | ||
}) | ||
|
||
test('remove', async () => { | ||
const actual = await favApiImpl.remove(1) | ||
expect(actual).toEqual([]) | ||
}) | ||
|
||
test('list', async () => { | ||
const actual = await favApiImpl.list() | ||
expect(actual).toEqual([]) | ||
}) | ||
}) | ||
}) |
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