File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,26 @@ describe('encodePaginationTokens', () => {
3838 expect ( response . previous ) . toEqual ( bsonUrlEncoding . encode ( [ 'Test' , '456' ] ) ) ;
3939 } ) ;
4040
41+ it ( 'encodes tokens when cursor is a plain object that lacks _id' , ( ) => {
42+ const params = {
43+ paginatedField : 'name' ,
44+ } ;
45+
46+ const response = {
47+ results : [ ] ,
48+ previous : { name : 'Alpha' } , // ⬅️ no _id
49+ hasPrevious : false ,
50+ next : { name : 'Beta' } , // ⬅️ no _id
51+ hasNext : false ,
52+ } as any ;
53+
54+ encodePaginationTokens ( params , response ) ;
55+
56+ expect ( response . previous ) . toEqual ( bsonUrlEncoding . encode ( 'Alpha' ) ) ;
57+ expect ( response . next ) . toEqual ( bsonUrlEncoding . encode ( 'Beta' ) ) ;
58+ } ) ;
59+
60+
4161 describe ( 'generateCursorQuery' , ( ) => {
4262 it ( 'generates an empty cursor query when no next or previous cursor is provided' , ( ) => {
4363 const params = {
You can’t perform that action at this time.
0 commit comments