@@ -369,8 +369,16 @@ describe('connectionResolver', () => {
369
369
} ) ;
370
370
371
371
describe ( 'HasNextPage' , ( ) => {
372
- it ( 'If first was not set, return false.' , ( ) => {
373
- expect ( preparePageInfo ( fiveEdges , { } , 4 , 0 ) . hasNextPage ) . toBe ( false ) ;
372
+ it ( 'If first was not set (and last is empty), return true.' , ( ) => {
373
+ // By current Relay Cursor Connections Specification
374
+ // if `first` and `last` are empty `hasNextPage` should be false.
375
+ // This rule is deviation from specification for better dev experience:
376
+ // when first and last args are empty
377
+ // we should check if exist more edges and provide correct `hasNextPage` value.
378
+ expect ( preparePageInfo ( fiveEdges , { } , 4 , 0 ) . hasNextPage ) . toBe ( true ) ;
379
+ } ) ;
380
+ it ( 'If first was not set (but last is present), return false.' , ( ) => {
381
+ expect ( preparePageInfo ( fiveEdges , { last : 200 } , 4 , 0 ) . hasNextPage ) . toBe ( false ) ;
374
382
} ) ;
375
383
it ( 'If edges contains more than first elements, return true.' , ( ) => {
376
384
expect ( preparePageInfo ( fiveEdges , { first : 4 } , 4 , 0 ) . hasNextPage ) . toBe ( true ) ;
0 commit comments