Commit 51417da 1 parent 209bb27 commit 51417da Copy full SHA for 51417da
File tree 2 files changed +24
-9
lines changed
2 files changed +24
-9
lines changed Original file line number Diff line number Diff line change @@ -14,10 +14,16 @@ describe('API giphy', () => {
14
14
data : [
15
15
{
16
16
images : {
17
- fixed_height : { url : 'normal.gif?extra' } ,
17
+ original : { url : 'original.gif?extra' } ,
18
+ fixed_height : { url : 'medium.gif?extra' } ,
18
19
fixed_height_small : { url : 'small.gif?extra' } ,
19
20
} ,
20
21
} ,
22
+ {
23
+ images : {
24
+ original : { url : 'original2.gif' } ,
25
+ } ,
26
+ } ,
21
27
] ,
22
28
} ) ;
23
29
} ) ;
@@ -48,7 +54,10 @@ describe('API giphy', () => {
48
54
. expect ( 'Content-Type' , / a p p l i c a t i o n \/ j s o n / ) ;
49
55
50
56
expect ( response . body ) . toEqual ( {
51
- gifs : [ { small : 'small.gif' , medium : 'normal.gif' } ] ,
57
+ gifs : [
58
+ { small : 'small.gif' , medium : 'medium.gif' } ,
59
+ { small : 'original2.gif' , medium : 'original2.gif' } ,
60
+ ] ,
52
61
} ) ;
53
62
} ) ;
54
63
Original file line number Diff line number Diff line change @@ -14,13 +14,14 @@ interface GifInfo {
14
14
}
15
15
16
16
interface GiphyResponseResource {
17
- url : string ;
17
+ url ? : string ;
18
18
}
19
19
20
20
interface GiphyResponseGif {
21
21
images : {
22
- fixed_height : GiphyResponseResource ;
23
- fixed_height_small : GiphyResponseResource ;
22
+ original ?: GiphyResponseResource ;
23
+ fixed_height ?: GiphyResponseResource ;
24
+ fixed_height_small ?: GiphyResponseResource ;
24
25
} ;
25
26
}
26
27
@@ -75,10 +76,15 @@ export class GiphyService {
75
76
throw new Error ( `Unknown Giphy API response: ${ resultJson . status } ` ) ;
76
77
}
77
78
78
- return resultJson . data . map ( ( gif ) => ( {
79
- small : gif . images . fixed_height_small . url . split ( '?' ) [ 0 ] ?? '' ,
80
- medium : gif . images . fixed_height . url . split ( '?' ) [ 0 ] ?? '' ,
81
- } ) ) ;
79
+ return resultJson . data . map ( ( gif ) => {
80
+ const original = gif . images . original ?. url ?? '' ;
81
+ const fixed = gif . images . fixed_height ?. url ?? original ;
82
+ const small = gif . images . fixed_height_small ?. url ?? fixed ;
83
+ return {
84
+ small : small . split ( '?' ) [ 0 ] ?? '' ,
85
+ medium : fixed . split ( '?' ) [ 0 ] ?? '' ,
86
+ } ;
87
+ } ) ;
82
88
} ,
83
89
( c ) => c . length >= limit ,
84
90
) ;
You can’t perform that action at this time.
0 commit comments