@@ -36,9 +36,22 @@ describe('getCollectionSlugMap', () => {
3636 transactions : true ,
3737 }
3838
39- it ( 'should return default slug map when no overrides are provided ' , ( ) => {
39+ it ( 'should return default slug map without variant slugs when enableVariants is false ' , ( ) => {
4040 const result = getCollectionSlugMap ( { sanitizedPluginConfig : baseConfig } )
4141
42+ expect ( result ) . toEqual ( {
43+ addresses : 'addresses' ,
44+ carts : 'carts' ,
45+ customers : 'users' ,
46+ orders : 'orders' ,
47+ products : 'products' ,
48+ transactions : 'transactions' ,
49+ } )
50+ } )
51+
52+ it ( 'should return default slug map with variant slugs when enableVariants is true' , ( ) => {
53+ const result = getCollectionSlugMap ( { enableVariants : true , sanitizedPluginConfig : baseConfig } )
54+
4255 expect ( result ) . toEqual ( {
4356 addresses : 'addresses' ,
4457 carts : 'carts' ,
@@ -60,12 +73,12 @@ describe('getCollectionSlugMap', () => {
6073 } ,
6174 }
6275
63- const result = getCollectionSlugMap ( { sanitizedPluginConfig : config } )
76+ const result = getCollectionSlugMap ( { enableVariants : true , sanitizedPluginConfig : config } )
6477
6578 expect ( result . customers ) . toBe ( 'custom-users' )
6679 } )
6780
68- it ( 'should apply slugMap overrides' , ( ) => {
81+ it ( 'should apply slugMap overrides when variants enabled ' , ( ) => {
6982 const config : SanitizedEcommercePluginConfig = {
7083 ...baseConfig ,
7184 slugMap : {
@@ -75,7 +88,7 @@ describe('getCollectionSlugMap', () => {
7588 } ,
7689 }
7790
78- const result = getCollectionSlugMap ( { sanitizedPluginConfig : config } )
91+ const result = getCollectionSlugMap ( { enableVariants : true , sanitizedPluginConfig : config } )
7992
8093 expect ( result . products ) . toBe ( 'custom-products' )
8194 expect ( result . variants ) . toBe ( 'custom-variants' )
@@ -85,6 +98,23 @@ describe('getCollectionSlugMap', () => {
8598 expect ( result . carts ) . toBe ( 'carts' )
8699 } )
87100
101+ it ( 'should not apply variant slugMap overrides when variants disabled' , ( ) => {
102+ const config : SanitizedEcommercePluginConfig = {
103+ ...baseConfig ,
104+ slugMap : {
105+ products : 'custom-products' ,
106+ variants : 'custom-variants' ,
107+ orders : 'custom-orders' ,
108+ } ,
109+ }
110+
111+ const result = getCollectionSlugMap ( { enableVariants : false , sanitizedPluginConfig : config } )
112+
113+ expect ( result . products ) . toBe ( 'custom-products' )
114+ expect ( result . variants ) . toBeUndefined ( )
115+ expect ( result . orders ) . toBe ( 'custom-orders' )
116+ } )
117+
88118 it ( 'should prioritize slugMap overrides over customers slug' , ( ) => {
89119 const config : SanitizedEcommercePluginConfig = {
90120 ...baseConfig ,
@@ -96,20 +126,20 @@ describe('getCollectionSlugMap', () => {
96126 } ,
97127 }
98128
99- const result = getCollectionSlugMap ( { sanitizedPluginConfig : config } )
129+ const result = getCollectionSlugMap ( { enableVariants : true , sanitizedPluginConfig : config } )
100130
101131 expect ( result . customers ) . toBe ( 'overridden-users' )
102132 } )
103133
104- it ( 'should handle partial slugMap overrides' , ( ) => {
134+ it ( 'should handle partial slugMap overrides with variants enabled ' , ( ) => {
105135 const config : SanitizedEcommercePluginConfig = {
106136 ...baseConfig ,
107137 slugMap : {
108138 products : 'items' ,
109139 } ,
110140 }
111141
112- const result = getCollectionSlugMap ( { sanitizedPluginConfig : config } )
142+ const result = getCollectionSlugMap ( { enableVariants : true , sanitizedPluginConfig : config } )
113143
114144 expect ( result . products ) . toBe ( 'items' )
115145 expect ( result . addresses ) . toBe ( 'addresses' )
@@ -122,13 +152,34 @@ describe('getCollectionSlugMap', () => {
122152 expect ( result . variantTypes ) . toBe ( 'variantTypes' )
123153 } )
124154
125- it ( 'should handle empty slugMap' , ( ) => {
155+ it ( 'should handle partial slugMap overrides with variants disabled' , ( ) => {
156+ const config : SanitizedEcommercePluginConfig = {
157+ ...baseConfig ,
158+ slugMap : {
159+ products : 'items' ,
160+ } ,
161+ }
162+
163+ const result = getCollectionSlugMap ( { enableVariants : false , sanitizedPluginConfig : config } )
164+
165+ expect ( result . products ) . toBe ( 'items' )
166+ expect ( result . addresses ) . toBe ( 'addresses' )
167+ expect ( result . carts ) . toBe ( 'carts' )
168+ expect ( result . customers ) . toBe ( 'users' )
169+ expect ( result . orders ) . toBe ( 'orders' )
170+ expect ( result . transactions ) . toBe ( 'transactions' )
171+ expect ( result . variants ) . toBeUndefined ( )
172+ expect ( result . variantOptions ) . toBeUndefined ( )
173+ expect ( result . variantTypes ) . toBeUndefined ( )
174+ } )
175+
176+ it ( 'should handle empty slugMap with variants enabled' , ( ) => {
126177 const config : SanitizedEcommercePluginConfig = {
127178 ...baseConfig ,
128179 slugMap : { } ,
129180 }
130181
131- const result = getCollectionSlugMap ( { sanitizedPluginConfig : config } )
182+ const result = getCollectionSlugMap ( { enableVariants : true , sanitizedPluginConfig : config } )
132183
133184 expect ( result ) . toEqual ( {
134185 addresses : 'addresses' ,
@@ -143,13 +194,31 @@ describe('getCollectionSlugMap', () => {
143194 } )
144195 } )
145196
146- it ( 'should handle undefined slugMap' , ( ) => {
197+ it ( 'should handle empty slugMap with variants disabled' , ( ) => {
198+ const config : SanitizedEcommercePluginConfig = {
199+ ...baseConfig ,
200+ slugMap : { } ,
201+ }
202+
203+ const result = getCollectionSlugMap ( { enableVariants : false , sanitizedPluginConfig : config } )
204+
205+ expect ( result ) . toEqual ( {
206+ addresses : 'addresses' ,
207+ carts : 'carts' ,
208+ customers : 'users' ,
209+ orders : 'orders' ,
210+ products : 'products' ,
211+ transactions : 'transactions' ,
212+ } )
213+ } )
214+
215+ it ( 'should handle undefined slugMap with variants enabled' , ( ) => {
147216 const config : SanitizedEcommercePluginConfig = {
148217 ...baseConfig ,
149218 slugMap : undefined ,
150219 }
151220
152- const result = getCollectionSlugMap ( { sanitizedPluginConfig : config } )
221+ const result = getCollectionSlugMap ( { enableVariants : true , sanitizedPluginConfig : config } )
153222
154223 expect ( result ) . toEqual ( {
155224 addresses : 'addresses' ,
@@ -163,4 +232,22 @@ describe('getCollectionSlugMap', () => {
163232 variantTypes : 'variantTypes' ,
164233 } )
165234 } )
235+
236+ it ( 'should handle undefined slugMap with variants disabled' , ( ) => {
237+ const config : SanitizedEcommercePluginConfig = {
238+ ...baseConfig ,
239+ slugMap : undefined ,
240+ }
241+
242+ const result = getCollectionSlugMap ( { enableVariants : false , sanitizedPluginConfig : config } )
243+
244+ expect ( result ) . toEqual ( {
245+ addresses : 'addresses' ,
246+ carts : 'carts' ,
247+ customers : 'users' ,
248+ orders : 'orders' ,
249+ products : 'products' ,
250+ transactions : 'transactions' ,
251+ } )
252+ } )
166253} )
0 commit comments