@@ -174,28 +174,28 @@ describe('endpoint overrides', () => {
174174 } ) ;
175175} ) ;
176176
177- describe ( 'option encodeParams ' , ( ) => {
177+ describe ( 'option encodePathParams ' , ( ) => {
178178 const config = {
179179 apiFile : './fixtures/emptyApi.ts' ,
180180 schemaFile : resolve ( __dirname , 'fixtures/petstore.json' ) ,
181- encodeParams : true ,
181+ encodePathParams : true ,
182182 } ;
183183
184- it ( 'should encode query parameters' , async ( ) => {
184+ it ( 'should encode path parameters' , async ( ) => {
185185 const api = await generateEndpoints ( {
186186 ...config ,
187- filterEndpoints : [ 'findPetsByStatus ' ] ,
187+ filterEndpoints : [ 'getOrderById ' ] ,
188188 } ) ;
189- expect ( api ) . toContain ( 'status: encodeURIComponent(String(queryArg.status))' ) ;
189+ // eslint-disable-next-line no-template-curly-in-string
190+ expect ( api ) . toContain ( '`/store/order/${encodeURIComponent(String(queryArg.orderId))}`' ) ;
190191 } ) ;
191192
192- it ( 'should encode path parameters' , async ( ) => {
193+ it ( 'should not encode query parameters' , async ( ) => {
193194 const api = await generateEndpoints ( {
194195 ...config ,
195- filterEndpoints : [ 'getOrderById ' ] ,
196+ filterEndpoints : [ 'findPetsByStatus ' ] ,
196197 } ) ;
197- // eslint-disable-next-line no-template-curly-in-string
198- expect ( api ) . toContain ( '`/store/order/${encodeURIComponent(String(queryArg.orderId))}`' ) ;
198+ expect ( api ) . toContain ( 'status: queryArg.status' ) ;
199199 } ) ;
200200
201201 it ( 'should not encode body parameters' , async ( ) => {
@@ -217,18 +217,60 @@ describe('option encodeParams', () => {
217217 expect ( api ) . toContain ( '`/store/order/${encodeURIComponent(String(queryArg))}`' ) ;
218218 } ) ;
219219
220- it ( 'should not encode parameters when encodeParams is false' , async ( ) => {
220+ it ( 'should not encode path parameters when encodePathParams is false' , async ( ) => {
221221 const api = await generateEndpoints ( {
222222 ...config ,
223- encodeParams : false ,
223+ encodePathParams : false ,
224224 filterEndpoints : [ 'findPetsByStatus' , 'getOrderById' ] ,
225225 } ) ;
226- expect ( api ) . toContain ( 'status: queryArg.status' ) ;
227226 // eslint-disable-next-line no-template-curly-in-string
228227 expect ( api ) . toContain ( '`/store/order/${queryArg.orderId}`' ) ;
229228 } ) ;
230229} ) ;
231230
231+ describe ( 'option encodeQueryParams' , ( ) => {
232+ const config = {
233+ apiFile : './fixtures/emptyApi.ts' ,
234+ schemaFile : resolve ( __dirname , 'fixtures/petstore.json' ) ,
235+ encodeQueryParams : true ,
236+ } ;
237+
238+ it ( 'should encode query parameters' , async ( ) => {
239+ const api = await generateEndpoints ( {
240+ ...config ,
241+ filterEndpoints : [ 'findPetsByStatus' ] ,
242+ } ) ;
243+ expect ( api ) . toContain ( 'status: encodeURIComponent(String(queryArg.status))' ) ;
244+ } ) ;
245+
246+ it ( 'should not encode path parameters' , async ( ) => {
247+ const api = await generateEndpoints ( {
248+ ...config ,
249+ filterEndpoints : [ 'getOrderById' ] ,
250+ } ) ;
251+ // eslint-disable-next-line no-template-curly-in-string
252+ expect ( api ) . toContain ( '`/store/order/${queryArg.orderId}`' ) ;
253+ } ) ;
254+
255+ it ( 'should not encode body parameters' , async ( ) => {
256+ const api = await generateEndpoints ( {
257+ ...config ,
258+ filterEndpoints : [ 'addPet' ] ,
259+ } ) ;
260+ expect ( api ) . toContain ( 'body: queryArg.pet' ) ;
261+ expect ( api ) . not . toContain ( 'body: encodeURIComponent(String(queryArg.pet))' ) ;
262+ } ) ;
263+
264+ it ( 'should not encode query parameters when encodeQueryParams is false' , async ( ) => {
265+ const api = await generateEndpoints ( {
266+ ...config ,
267+ encodeQueryParams : false ,
268+ filterEndpoints : [ 'findPetsByStatus' , 'getOrderById' ] ,
269+ } ) ;
270+ expect ( api ) . toContain ( 'status: queryArg.status' ) ;
271+ } ) ;
272+ } ) ;
273+
232274describe ( 'option flattenArg' , ( ) => {
233275 const config = {
234276 apiFile : './fixtures/emptyApi.ts' ,
0 commit comments