File tree Expand file tree Collapse file tree 2 files changed +17
-6
lines changed
Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -470,9 +470,9 @@ for (let funcName of ['getBasicInfo', 'getInfo']) {
470470 * @returns {Promise<Object> }
471471 */
472472 const func = exports [ funcName ] ;
473- exports [ funcName ] = ( link , options = { } ) => {
473+ exports [ funcName ] = async ( link , options = { } ) => {
474474 utils . checkForUpdates ( ) ;
475- let id = urlUtils . getVideoID ( link ) ;
475+ let id = await urlUtils . getVideoID ( link ) ;
476476 const key = [ funcName , id , options . lang ] . join ( '-' ) ;
477477 return exports . cache . getOrSet ( key , ( ) => func ( id , options ) ) ;
478478 } ;
Original file line number Diff line number Diff line change @@ -452,11 +452,22 @@ describe('ytdl.getBasicInfo()', () => {
452452 } ) ;
453453
454454 describe ( 'With a bad video ID' , ( ) => {
455- it ( 'Returns an error' , ( ) => {
455+ it ( 'Throws a catchable error' , async ( ) => {
456456 const id = 'bad' ;
457- assert . throws ( ( ) => {
458- ytdl . getBasicInfo ( id ) ;
459- } , / N o v i d e o i d f o u n d : b a d / ) ;
457+ try {
458+ await ytdl . getBasicInfo ( id ) ;
459+ } catch ( err ) {
460+ assert . ok ( / N o v i d e o i d f o u n d / . test ( err . message ) ) ;
461+ return ;
462+ }
463+ throw Error ( 'should not get here' ) ;
464+ } ) ;
465+ it ( 'Promise is rejected with caught error' , done => {
466+ const id = 'https://website.com' ;
467+ ytdl . getBasicInfo ( id ) . catch ( err => {
468+ assert . ok ( / N o t a Y o u T u b e d o m a i n / . test ( err . message ) ) ;
469+ done ( ) ;
470+ } ) ;
460471 } ) ;
461472 } ) ;
462473
You can’t perform that action at this time.
0 commit comments