@@ -232,20 +232,41 @@ function searchProvider(
232232describe ( "GitHub repository search" , ( ) => {
233233 beforeEach ( journalBeforeEach ( OWNER ) ) ;
234234
235+ it ( "runs the search and Query example with the original page as its input" , function * ( ) {
236+ const remote = yield * useBareRemote ( REMOTE ) ;
237+ const checkout = yield * useNamedOriginCheckout ( remote , REPOSITORY ) ;
238+ const root = yield * useTempDirectory ( "github-search" ) ;
239+ const page = { ...FIRST_PAGE , total_count : 1 } ;
240+ const provider = searchProvider ( [ REPOSITORY ] , ( ) => ( {
241+ status : 200 ,
242+ body : JSON . stringify ( page ) ,
243+ } ) ) ;
244+ const output = yield * runOrdinaryDocument (
245+ [
246+ '<GitHub.Search query="is:pr is:open label:bug" sort="created" perPage={20} as="page" />' ,
247+ '<Query value={page} yq="[.items[].html_url]" as="pullRequestUrls" />' ,
248+ "<Json value={{ page, pullRequestUrls }} />" ,
249+ ] . join ( "\n" ) ,
250+ { cwd : checkout . root , root, gitHubPullRequests : provider . options } ,
251+ ) ;
252+ expect ( JSON . parse ( String ( output ) ) ) . toEqual ( { page, pullRequestUrls : [ ITEM . html_url ] } ) ;
253+ expect ( provider . requests ) . toHaveLength ( 1 ) ;
254+ } ) ;
255+
235256 it ( "binds original pages, projects URLs and exposes only reusable continuation arguments" , function * ( ) {
236257 const remote = yield * useBareRemote ( REMOTE ) ;
237258 const checkout = yield * useNamedOriginCheckout ( remote , REPOSITORY ) ;
238259 const root = yield * useTempDirectory ( "github-search" ) ;
239260 const provider = searchProvider ( ) ;
240261 const output = yield * runOrdinaryDocument (
241262 [
242- `<GitHub.Search query={${ JSON . stringify ( QUERY ) } } sort="created" perPage={1} as="first" />` ,
243- '<Query value={first.value } yq="[.items[].html_url]" as="urls" />' ,
263+ `<GitHub.Search query={${ JSON . stringify ( QUERY ) } } sort="created" perPage={1} as="first" nextAs="next" />` ,
264+ '<Query value={first} yq="[.items[].html_url]" as="urls" />' ,
244265 '<PullRequest.Reviews url={urls[0]} as="reviews" />' ,
245- '<GitHub.Search query={first. next.query} sort={first. next.sort} order={first. next.order} page={first. next.page} perPage={first. next.perPage} as="second" />' ,
246- '<GitHub.Search query="is:issue" page={10} perPage={100} as="ceiling" />' ,
266+ '<GitHub.Search query={next.query} sort={next.sort} order={next.order} page={next.page} perPage={next.perPage} as="second" nextAs="after " />' ,
267+ '<GitHub.Search query="is:issue" page={10} perPage={100} as="ceiling" nextAs="beyond" />' ,
247268 "" ,
248- "<Json value={{ first, second, ceiling, urls, reviews }} />" ,
269+ "<Json value={{ first, next, second, after, ceiling, beyond , urls, reviews }} />" ,
249270 ] . join ( "\n" ) ,
250271 {
251272 cwd : checkout . root ,
@@ -254,12 +275,12 @@ describe("GitHub repository search", () => {
254275 } ,
255276 ) ;
256277 expect ( JSON . parse ( String ( output ) ) ) . toEqual ( {
257- first : {
258- value : FIRST_PAGE ,
259- next : { query : QUERY , sort : "created" , order : "desc" , page : 2 , perPage : 1 } ,
260- } ,
261- second : { value : { total_count : 2 , incomplete_results : true , items : [ ] } , next : null } ,
262- ceiling : { value : { total_count : 1500 , incomplete_results : true , items : [ ] } , next : null } ,
278+ first : FIRST_PAGE ,
279+ next : { query : QUERY , sort : "created" , order : "desc" , page : 2 , perPage : 1 } ,
280+ second : { total_count : 2 , incomplete_results : true , items : [ ] } ,
281+ after : null ,
282+ ceiling : { total_count : 1500 , incomplete_results : true , items : [ ] } ,
283+ beyond : null ,
263284 urls : [ ITEM . html_url ] ,
264285 reviews : [ ] ,
265286 } ) ;
@@ -294,6 +315,8 @@ describe("GitHub repository search", () => {
294315 [ checkout . root , 'query="is:issue is:pr"' , "exactly one kind" ] ,
295316 [ checkout . root , 'query="is:open"' , "exactly one kind" ] ,
296317 [ checkout . root , 'query="is:pr" page={11} perPage={100}' , "first 1,000" ] ,
318+ [ checkout . root , 'query="is:pr" nextAs="page"' , "Duplicate result binding" ] ,
319+ [ checkout . root , 'query="is:pr" nextAs="class"' , "valid JavaScript binding name" ] ,
297320 [ checkout . root , 'query="is:pr"' , "has not authorized" ] ,
298321 [ local . root , 'query="is:pr"' , "does not name a GitHub repository" ] ,
299322 [ outside , 'query="is:pr"' , "repository" ] ,
@@ -390,9 +413,9 @@ describe("GitHub repository search", () => {
390413 const provider = searchProvider ( ) ;
391414 const source = [
392415 `<Repository name="search" url="${ REPOSITORY } ">` ,
393- '<GitHub.Search query="is:pr" perPage={1} as="page" />' ,
416+ '<GitHub.Search query="is:pr" perPage={1} as="page" nextAs="next" />' ,
394417 "" ,
395- "<Json value={page.value } />" ,
418+ "<Json value={{ page, next } } />" ,
396419 "</Repository>" ,
397420 ] . join ( "\n" ) ;
398421 yield * withStorage ( root , function * ( ) {
0 commit comments