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', () => {
38
38
expect ( response . previous ) . toEqual ( bsonUrlEncoding . encode ( [ 'Test' , '456' ] ) ) ;
39
39
} ) ;
40
40
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
+
41
61
describe ( 'generateCursorQuery' , ( ) => {
42
62
it ( 'generates an empty cursor query when no next or previous cursor is provided' , ( ) => {
43
63
const params = {
You can’t perform that action at this time.
0 commit comments