@@ -1002,10 +1002,12 @@ describe("Web Search API", () => {
10021002
10031003 // Check structure of search results
10041004 for ( const searchResult of result . results ) {
1005+ console . log ( searchResult . title ) ;
10051006 expectProperty ( searchResult , "title" ) ;
10061007 expectProperty ( searchResult , "url" ) ;
10071008 expectProperty ( searchResult , "description" ) ;
1008- expectProperty ( searchResult , "content" ) ;
1009+ // this could also be null after 4 search results
1010+ // expectProperty(searchResult, "content");
10091011 expectProperty ( searchResult , "is_safe" ) ;
10101012 expectProperty ( searchResult , "site_name" ) ;
10111013 expectProperty ( searchResult , "language" ) ;
@@ -1014,6 +1016,11 @@ describe("Web Search API", () => {
10141016 expectType ( searchResult . url , "string" ) ;
10151017 expectType ( searchResult . description , "string" ) ;
10161018 expectType ( searchResult . is_safe , "boolean" ) ;
1019+
1020+ // content can be string or null
1021+ if ( searchResult . content !== null && typeof searchResult . content !== "string" ) {
1022+ throw new Error ( `Expected content to be string or null, got ${ typeof searchResult . content } ` ) ;
1023+ }
10171024 }
10181025 } ) ;
10191026
0 commit comments