File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -101,4 +101,33 @@ describe("buildPaginationMeta", () => {
101
101
102
102
expect ( nextQuery ) . toBe ( null ) ;
103
103
} ) ;
104
+
105
+ test ( "API修正前ロジック: 同じクエリパラメータが 2 回以上指定されていてもそのまま処理できる" , ( ) => {
106
+ const currentQuery = {
107
+ note_status : [ "CURRENTLY_RATED_HELPFUL" , "NEEDS_MORE_RATINGS" ] ,
108
+ limit : 10 ,
109
+ offset : 10 ,
110
+ } satisfies z . infer < typeof noteSearchParamSchema > ;
111
+
112
+ const currentBrokenMeta = {
113
+ // API が note_status を複数回指定した際、最後のもの以外を削除してしまう挙動を再現
114
+ next : "https://example.com/api/v1/data/search?note_status=NEEDS_MORE_RATINGS&limit=10&offset=20" ,
115
+ prev : "https://example.com/api/v1/data/search?note_status=NEEDS_MORE_RATINGS&limit=10&offset=0" ,
116
+ } satisfies PaginationMeta ;
117
+
118
+ const fixedMeta = buildPaginationMeta ( currentBrokenMeta , currentQuery ) ;
119
+ const prevQuery = fixedMeta . prev ? getQuery ( fixedMeta . prev ) : null ;
120
+ const nextQuery = fixedMeta . next ? getQuery ( fixedMeta . next ) : null ;
121
+
122
+ expect ( prevQuery ) . toStrictEqual ( {
123
+ note_status : [ "CURRENTLY_RATED_HELPFUL" , "NEEDS_MORE_RATINGS" ] ,
124
+ limit : "10" ,
125
+ offset : "0" ,
126
+ } ) ;
127
+ expect ( nextQuery ) . toStrictEqual ( {
128
+ note_status : [ "CURRENTLY_RATED_HELPFUL" , "NEEDS_MORE_RATINGS" ] ,
129
+ limit : "10" ,
130
+ offset : "20" ,
131
+ } ) ;
132
+ } ) ;
104
133
} ) ;
You can’t perform that action at this time.
0 commit comments