@@ -27,7 +27,7 @@ describe( 'scraping', function () {
2727 }
2828
2929 describe ( 'parseAll function' , ( ) => {
30- it ( 'should resolve promise from woorank' , ( ) => {
30+ it ( 'should resolve promise from woorank with headers ' , ( ) => {
3131 const url = 'https://www.woorank.com/en/blog/dublin-core-metadata-for-seo-and-usability' ;
3232 return meta ( { uri : url , headers : { 'User-Agent' : userAgent , Accept : acceptHeader } } )
3333 . then ( ( result ) => {
@@ -39,9 +39,9 @@ describe( 'scraping', function () {
3939 } ) ;
4040 } ) ;
4141
42- it ( 'should resolve promise from blog.schema.org' , ( ) => {
42+ it ( 'should resolve promise from blog.schema.org without headers ' , ( ) => {
4343 const url = 'http://blog.schema.org' ;
44- return meta ( { uri : url , headers : { 'User-Agent' : userAgent , Accept : acceptHeader } } )
44+ return meta ( url )
4545 . then ( ( result ) => {
4646 assert . ok ( result , 'Expected result to be truthy' ) ;
4747 } )
@@ -50,6 +50,39 @@ describe( 'scraping', function () {
5050 throw e ;
5151 } ) ;
5252 } ) ;
53+
54+ it ( 'should throw error if no uri supplied' , ( ) => meta ( )
55+ . then ( ( ) => {
56+ assert . fail ( 'Should have rejected the promise' ) ;
57+ } )
58+ . catch ( ( e ) => {
59+ assert . ok ( e instanceof Error , 'Error should be an Error object' ) ;
60+ assert . strictEqual ( e . message , 'No uri supplied in argument' , 'Error message should match expected message' ) ;
61+ } )
62+ ) ;
63+
64+ it ( 'should support await implementation with headers' , async ( ) => {
65+ const url = 'http://blog.schema.org' ;
66+ const result = await meta ( { uri : url , headers : { 'User-Agent' : userAgent , Accept : acceptHeader } } ) ;
67+ assert . ok ( result , 'Expected result to be truthy' ) ;
68+ } ) ;
69+
70+ it ( 'should support await implementation without headers' , async ( ) => {
71+ const url = 'http://blog.schema.org' ;
72+ const result = await meta ( url ) ;
73+ assert . ok ( result , 'Expected result to be truthy' ) ;
74+ } ) ;
75+
76+ it ( 'should throw error if no uri is supplied with async/await' , async ( ) => {
77+ try {
78+ await meta ( ) ;
79+ assert . fail ( 'Should have thrown an error' ) ;
80+ } catch ( e ) {
81+ assert . ok ( e instanceof Error , 'Error should be an Error object' ) ;
82+ assert . strictEqual ( e . message , 'No uri supplied in argument' , 'Error message should match expected message' ) ;
83+ }
84+ } ) ;
85+
5386 } ) ;
5487
5588 describe ( 'parseBEPress function' , ( ) => {
0 commit comments