@@ -172,6 +172,98 @@ describe('endpoint overrides', () => {
172172 expect ( api ) . not . toMatch ( / h e a d e r s : { / ) ;
173173 expect ( api ) . toMatchSnapshot ( 'should remove all parameters except for findPetsByStatus' ) ;
174174 } ) ;
175+
176+ it ( 'should override generated tags' , async ( ) => {
177+ const api = await generateEndpoints ( {
178+ unionUndefined : true ,
179+ tag : true ,
180+ apiFile : './fixtures/emptyApi.ts' ,
181+ schemaFile : resolve ( __dirname , 'fixtures/petstore.json' ) ,
182+ filterEndpoints : [ 'getPetById' , 'deletePet' ] ,
183+ endpointOverrides : [
184+ {
185+ pattern : 'getPetById' ,
186+ providesTags : [ 'CustomQueryTag' ] ,
187+ } ,
188+ {
189+ pattern : 'deletePet' ,
190+ invalidatesTags : [ ] ,
191+ } ,
192+ ] ,
193+ } ) ;
194+
195+ expect ( api ) . toMatch ( / g e t P e t B y I d : b u i l d \. q u e r y [ \s \S ] * p r o v i d e s T a g s : \[ " C u s t o m Q u e r y T a g " \] / ) ;
196+ expect ( api ) . not . toMatch ( / g e t P e t B y I d : b u i l d \. q u e r y [ \s \S ] * p r o v i d e s T a g s : \[ " p e t " \] / ) ;
197+ expect ( api ) . toMatch ( / d e l e t e P e t : b u i l d \. m u t a t i o n [ \s \S ] * i n v a l i d a t e s T a g s : \[ \] / ) ;
198+ expect ( api ) . not . toMatch ( / d e l e t e P e t : b u i l d \. m u t a t i o n [ \s \S ] * i n v a l i d a t e s T a g s : \[ " p e t " \] / ) ;
199+ } ) ;
200+
201+ it ( 'should allow tag overrides when tag generation is disabled' , async ( ) => {
202+ const api = await generateEndpoints ( {
203+ unionUndefined : true ,
204+ apiFile : './fixtures/emptyApi.ts' ,
205+ schemaFile : resolve ( __dirname , 'fixtures/petstore.json' ) ,
206+ filterEndpoints : [ 'getPetById' , 'deletePet' ] ,
207+ endpointOverrides : [
208+ {
209+ pattern : 'getPetById' ,
210+ providesTags : [ 'ManualProvides' ] ,
211+ } ,
212+ {
213+ pattern : 'deletePet' ,
214+ invalidatesTags : [ 'ManualInvalidates' ] ,
215+ } ,
216+ ] ,
217+ } ) ;
218+
219+ expect ( api ) . toMatch ( / g e t P e t B y I d : b u i l d \. q u e r y [ \s \S ] * p r o v i d e s T a g s : \[ " M a n u a l P r o v i d e s " \] / ) ;
220+ expect ( api ) . toMatch ( / d e l e t e P e t : b u i l d \. m u t a t i o n [ \s \S ] * i n v a l i d a t e s T a g s : \[ " M a n u a l I n v a l i d a t e s " \] / ) ;
221+ expect ( api ) . not . toMatch ( / p r o v i d e s T a g s : \[ \] / ) ;
222+ expect ( api ) . not . toMatch ( / i n v a l i d a t e s T a g s : \[ \] / ) ;
223+ } ) ;
224+
225+ it ( 'allows overriding tags regardless of inferred endpoint type' , async ( ) => {
226+ const api = await generateEndpoints ( {
227+ unionUndefined : true ,
228+ apiFile : './fixtures/emptyApi.ts' ,
229+ schemaFile : resolve ( __dirname , 'fixtures/petstore.json' ) ,
230+ filterEndpoints : 'loginUser' ,
231+ endpointOverrides : [
232+ {
233+ pattern : 'loginUser' ,
234+ type : 'mutation' ,
235+ providesTags : [ 'LoginStatus' ] ,
236+ } ,
237+ ] ,
238+ } ) ;
239+
240+ expect ( api ) . toMatch ( / l o g i n U s e r : b u i l d \. m u t a t i o n / ) ;
241+ expect ( api ) . toMatch ( / p r o v i d e s T a g s : \[ " L o g i n S t a t u s " \] / ) ;
242+ expect ( api ) . not . toMatch ( / i n v a l i d a t e s T a g s : / ) ;
243+ } ) ;
244+
245+ it ( 'allows overriding both providesTags and invalidatesTags simultaneously' , async ( ) => {
246+ const api = await generateEndpoints ( {
247+ unionUndefined : true ,
248+ tag : true ,
249+ apiFile : './fixtures/emptyApi.ts' ,
250+ schemaFile : resolve ( __dirname , 'fixtures/petstore.json' ) ,
251+ filterEndpoints : 'findPetsByStatus' ,
252+ endpointOverrides : [
253+ {
254+ pattern : 'findPetsByStatus' ,
255+ providesTags : [ 'CustomProvide' ] ,
256+ invalidatesTags : [ 'CustomInvalidate' ] ,
257+ } ,
258+ ] ,
259+ } ) ;
260+
261+ expect ( api ) . toMatch ( / f i n d P e t s B y S t a t u s : b u i l d \. q u e r y / ) ;
262+ expect ( api ) . toMatch ( / p r o v i d e s T a g s : \[ " C u s t o m P r o v i d e " \] / ) ;
263+ expect ( api ) . toMatch ( / i n v a l i d a t e s T a g s : \[ " C u s t o m I n v a l i d a t e " \] / ) ;
264+ expect ( api ) . not . toMatch ( / p r o v i d e s T a g s : \[ " p e t " \] / ) ;
265+ expect ( api ) . not . toMatch ( / i n v a l i d a t e s T a g s : \[ " p e t " \] / ) ;
266+ } ) ;
175267} ) ;
176268
177269describe ( 'option encodePathParams' , ( ) => {
0 commit comments