-
Notifications
You must be signed in to change notification settings - Fork 3
/
todo.test.js
29 lines (23 loc) · 943 Bytes
/
todo.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import * as commonApi from '../../api/common';
import * as api from '../../api/todo';
describe('getGiphy', () => {
let text;
let url;
beforeAll(() => {
text = 'text';
url = 'url';
});
it('calls the giphy api with correct parameters', () => {
spyOn(commonApi, 'get').and.returnValue(Promise.resolve({data: {images: {'fixed_height': {url}}}}));
return api.getGiphy(text).then(() => {
expect(commonApi.get)
.toHaveBeenCalledWith(`//api.giphy.com/v1/gifs/translate?s=${encodeURIComponent(text)}&api_key=dc6zaTOxFJmzC`);
});
});
it('parses the response from the giphy api and pulls off the fixed_height url', () => {
spyOn(commonApi, 'get').and.returnValue(Promise.resolve({data: {images: {'fixed_height': {url}}}}));
return api.getGiphy(text).then(response => {
expect(response).toEqual(url);
});
});
});