@@ -149,4 +149,48 @@ describe("core/scraper/reddit.js", function () {
149149 assert . deepEqual ( getAddons . mock . calls [ 0 ] . arguments , [ "video" ] ) ;
150150 } ) ;
151151 } ) ;
152+
153+ describe ( "extractOld()" , function ( ) {
154+ it ( "shouldn't handle when it's a unsupported URL" , async function ( ) {
155+ const url = new URL ( "https://www.redditinc.com/policies/" ) ;
156+ const file = await scraper . extractOld ( url ) ;
157+ assert . equal ( file , undefined ) ;
158+ } ) ;
159+
160+ it ( "should return undefined when it isn't a video on old.reddit" , async function ( ) {
161+ const url = new URL ( "https://old.reddit.com/r/foo" ) ;
162+ const metadata = {
163+ html : ( ) =>
164+ Promise . resolve (
165+ new DOMParser ( ) . parseFromString (
166+ '<html lang="en"><body></body></html>' ,
167+ "text/html" ,
168+ ) ,
169+ ) ,
170+ } ;
171+
172+ const file = await scraper . extractOld ( url , metadata ) ;
173+ assert . equal ( file , undefined ) ;
174+ } ) ;
175+
176+ it ( "should return video URL from old.reddit.com" , async function ( ) {
177+ const url = new URL ( "https://old.reddit.com/r/foo" ) ;
178+ const metadata = {
179+ html : ( ) =>
180+ Promise . resolve (
181+ new DOMParser ( ) . parseFromString (
182+ `<html lang="en"><body>
183+ <div
184+ data-hls-url="https://old.reddit.com/video.m3u8"
185+ ></div>
186+ </body></html>` ,
187+ "text/html" ,
188+ ) ,
189+ ) ,
190+ } ;
191+
192+ const file = await scraper . extractOld ( url , metadata ) ;
193+ assert . equal ( file , "https://old.reddit.com/video.m3u8" ) ;
194+ } ) ;
195+ } ) ;
152196} ) ;
0 commit comments