@@ -10,7 +10,7 @@ import * as scraper from "../../../../src/core/scraper/opengraph.js";
10
10
11
11
describe ( "core/scraper/opengraph.js" , function ( ) {
12
12
describe ( "extractVideo()" , function ( ) {
13
- it ( "shouldn't handle when it's a unsupported URL " , async function ( ) {
13
+ it ( "should return undefined when it isn't HTML " , async function ( ) {
14
14
const url = new URL ( "https://foo.com" ) ;
15
15
const content = { html : ( ) => Promise . resolve ( undefined ) } ;
16
16
const options = { depth : false } ;
@@ -19,26 +19,6 @@ describe("core/scraper/opengraph.js", function () {
19
19
assert . equal ( file , undefined ) ;
20
20
} ) ;
21
21
22
- it ( "should return undefined when there isn't Open Graph type" , async function ( ) {
23
- const url = new URL ( "https://foo.com" ) ;
24
- const content = {
25
- html : ( ) =>
26
- Promise . resolve (
27
- new DOMParser ( ) . parseFromString (
28
- `<html><head>
29
- <meta property="og:video"
30
- content="http://bar.com/" />
31
- </head></html>` ,
32
- "text/html" ,
33
- ) ,
34
- ) ,
35
- } ;
36
- const options = { depth : false } ;
37
-
38
- const file = await scraper . extractVideo ( url , content , options ) ;
39
- assert . equal ( file , undefined ) ;
40
- } ) ;
41
-
42
22
it ( "should return undefined when content is empty" , async function ( ) {
43
23
const url = new URL ( "https://foo.com" ) ;
44
24
const content = {
@@ -60,17 +40,15 @@ describe("core/scraper/opengraph.js", function () {
60
40
assert . equal ( file , undefined ) ;
61
41
} ) ;
62
42
63
- it ( "should return undefined when type isn't supported " , async function ( ) {
43
+ it ( "should return video URL when there isn't type " , async function ( ) {
64
44
const url = new URL ( "https://foo.com" ) ;
65
45
const content = {
66
46
html : ( ) =>
67
47
Promise . resolve (
68
48
new DOMParser ( ) . parseFromString (
69
49
`<html><head>
70
- <meta property="og:video:type"
71
- content="application/pdf" />
72
50
<meta property="og:video"
73
- content="http ://bar.com/baz.pdf " />
51
+ content="https ://bar.com/baz.hls " />
74
52
</head></html>` ,
75
53
"text/html" ,
76
54
) ,
@@ -79,7 +57,7 @@ describe("core/scraper/opengraph.js", function () {
79
57
const options = { depth : false } ;
80
58
81
59
const file = await scraper . extractVideo ( url , content , options ) ;
82
- assert . equal ( file , undefined ) ;
60
+ assert . equal ( file , "https://bar.com/baz.hls" ) ;
83
61
} ) ;
84
62
85
63
it ( "should return video URL" , async function ( ) {
@@ -104,7 +82,7 @@ describe("core/scraper/opengraph.js", function () {
104
82
assert . equal ( file , "http://bar.com/baz.mkv" ) ;
105
83
} ) ;
106
84
107
- it ( "should return undefined when content is unknown " , async function ( ) {
85
+ it ( "should return undefined when type isn't supported " , async function ( ) {
108
86
const spy = sinon . stub ( globalThis , "fetch" ) ;
109
87
110
88
const url = new URL ( "https://foo.com" ) ;
@@ -114,9 +92,9 @@ describe("core/scraper/opengraph.js", function () {
114
92
new DOMParser ( ) . parseFromString (
115
93
`<html><head>
116
94
<meta property="og:video:type"
117
- content="bar/baz " />
95
+ content="application/pdf " />
118
96
<meta property="og:video"
119
- content="http://qux .com/" />
97
+ content="http://bar .com/baz.pdf " />
120
98
</head></html>` ,
121
99
"text/html" ,
122
100
) ,
@@ -210,26 +188,6 @@ describe("core/scraper/opengraph.js", function () {
210
188
assert . equal ( file , undefined ) ;
211
189
} ) ;
212
190
213
- it ( "should return undefined when there isn't Open Graph type" , async function ( ) {
214
- const url = new URL ( "https://foo.com" ) ;
215
- const content = {
216
- html : ( ) =>
217
- Promise . resolve (
218
- new DOMParser ( ) . parseFromString (
219
- `<html><head>
220
- <meta property="og:audio"
221
- content="http://bar.com/" />
222
- </head></html>` ,
223
- "text/html" ,
224
- ) ,
225
- ) ,
226
- } ;
227
- const options = { depth : false } ;
228
-
229
- const file = await scraper . extractAudio ( url , content , options ) ;
230
- assert . equal ( file , undefined ) ;
231
- } ) ;
232
-
233
191
it ( "should return undefined when content is empty" , async function ( ) {
234
192
const url = new URL ( "https://foo.com" ) ;
235
193
const content = {
@@ -251,17 +209,15 @@ describe("core/scraper/opengraph.js", function () {
251
209
assert . equal ( file , undefined ) ;
252
210
} ) ;
253
211
254
- it ( "should return undefined when type isn't supported " , async function ( ) {
212
+ it ( "should return audio URL when there isn't type " , async function ( ) {
255
213
const url = new URL ( "https://foo.com" ) ;
256
214
const content = {
257
215
html : ( ) =>
258
216
Promise . resolve (
259
217
new DOMParser ( ) . parseFromString (
260
218
`<html><head>
261
- <meta property="og:audio:type"
262
- content="application/pdf" />
263
219
<meta property="og:audio"
264
- content="http ://bar.com/baz.pdf " />
220
+ content="https ://bar.com/baz.mp3 " />
265
221
</head></html>` ,
266
222
"text/html" ,
267
223
) ,
@@ -270,7 +226,7 @@ describe("core/scraper/opengraph.js", function () {
270
226
const options = { depth : false } ;
271
227
272
228
const file = await scraper . extractAudio ( url , content , options ) ;
273
- assert . equal ( file , undefined ) ;
229
+ assert . equal ( file , "https://bar.com/baz.mp3" ) ;
274
230
} ) ;
275
231
276
232
it ( "should return audio URL" , async function ( ) {
@@ -295,7 +251,7 @@ describe("core/scraper/opengraph.js", function () {
295
251
assert . equal ( file , "http://bar.com/baz.wav" ) ;
296
252
} ) ;
297
253
298
- it ( "should return undefined when content is unknown " , async function ( ) {
254
+ it ( "should return undefined when type isn't supported " , async function ( ) {
299
255
const spy = sinon . stub ( globalThis , "fetch" ) ;
300
256
301
257
const url = new URL ( "https://foo.com" ) ;
0 commit comments