@@ -18,26 +18,46 @@ describe("core/scraper/flickr.js", function () {
18
18
} ) ;
19
19
20
20
it ( "should return undefined when it isn't a video" , async function ( ) {
21
+ const stub = sinon
22
+ . stub ( globalThis , "fetch" )
23
+ . resolves ( Response . json ( { } ) ) ;
24
+
21
25
const url = new URL ( "https://www.flickr.com/photos/foo" ) ;
22
26
const metadata = {
23
27
html : ( ) =>
24
28
Promise . resolve (
25
29
new DOMParser ( ) . parseFromString (
26
- "<html><body></body></html>" ,
30
+ `<html><head>
31
+ <meta property="og:image"
32
+ content="https://live.staticflickr.com` +
33
+ `/bar/baz_qux_b.jpg">
34
+ </head><body>
35
+ <script>
36
+ root.YUI_config.flickr.api.site_key = "quux";
37
+ </script>
38
+ </body></html>` ,
27
39
"text/html" ,
28
40
) ,
29
41
) ,
30
42
} ;
31
43
32
44
const file = await scraper . extract ( url , metadata ) ;
33
45
assert . equal ( file , undefined ) ;
46
+
47
+ assert . equal ( stub . callCount , 1 ) ;
48
+ assert . deepEqual ( stub . firstCall . args , [
49
+ "https://api.flickr.com/services/rest" +
50
+ "?method=flickr.video.getStreamInfo&format=json" +
51
+ "&nojsoncallback=1&photo_id=baz&secret=qux" +
52
+ "&api_key=quux" ,
53
+ ] ) ;
34
54
} ) ;
35
55
36
56
it ( "should return video URL" , async function ( ) {
37
57
const stub = sinon . stub ( globalThis , "fetch" ) . resolves (
38
58
Response . json ( {
39
59
streams : {
40
- stream : [ { _content : "https://foo.net /bar.mp4" } ] ,
60
+ stream : [ { _content : "https://foo.com /bar.mp4" } ] ,
41
61
} ,
42
62
} ) ,
43
63
) ;
@@ -47,27 +67,29 @@ describe("core/scraper/flickr.js", function () {
47
67
html : ( ) =>
48
68
Promise . resolve (
49
69
new DOMParser ( ) . parseFromString (
50
- `<html><body>
70
+ `<html><head>
71
+ <meta property="og:image"
72
+ content="https://live.staticflickr.com` +
73
+ `/qux/quux_corge_b.jpg">
74
+ </head><body>
51
75
<script>
52
- root.YUI_config.flickr.api.site_key = "qux ";
76
+ root.YUI_config.flickr.api.site_key = "grault ";
53
77
</script>
54
- <video poster="//quux.com/corge` +
55
- `/grault_garply.jpg" />
56
78
</body></html>` ,
57
79
"text/html" ,
58
80
) ,
59
81
) ,
60
82
} ;
61
83
62
84
const file = await scraper . extract ( url , metadata ) ;
63
- assert . equal ( file , "https://foo.net /bar.mp4" ) ;
85
+ assert . equal ( file , "https://foo.com /bar.mp4" ) ;
64
86
65
87
assert . equal ( stub . callCount , 1 ) ;
66
88
assert . deepEqual ( stub . firstCall . args , [
67
89
"https://api.flickr.com/services/rest" +
68
90
"?method=flickr.video.getStreamInfo&format=json" +
69
- "&nojsoncallback=1&photo_id=grault &secret=garply " +
70
- "&api_key=qux " ,
91
+ "&nojsoncallback=1&photo_id=quux &secret=corge " +
92
+ "&api_key=grault " ,
71
93
] ) ;
72
94
} ) ;
73
95
} ) ;
0 commit comments