@@ -100,7 +100,9 @@ describe('wrappingLoader', () => {
100100
101101 await loaderPromise ;
102102
103- expect ( callback ) . toHaveBeenCalledWith ( null , expect . stringContaining ( "'/my/route'" ) , expect . anything ( ) ) ;
103+ // Accept either single- or double-quoted string literals — the wrapper-template source
104+ // uses single quotes, but esbuild rewrites them to double quotes during transpile.
105+ expect ( callback ) . toHaveBeenCalledWith ( null , expect . stringMatching ( / [ ' " ] \/ m y \/ r o u t e [ ' " ] / ) , expect . anything ( ) ) ;
104106 } ) ;
105107
106108 describe ( 'middleware wrapping' , ( ) => {
@@ -148,8 +150,8 @@ describe('wrappingLoader', () => {
148150 expect ( wrappedCode ) . toContain ( 'userProvidedProxy = true' ) ;
149151
150152 // Proxy should be wrapped, middleware should be undefined
151- expect ( wrappedCode ) . toMatch ( / c o n s t p r o x y = u s e r P r o v i d e d P r o x y \? w r a p p e d H a n d l e r : u n d e f i n e d / ) ;
152- expect ( wrappedCode ) . toMatch ( / c o n s t m i d d l e w a r e = u s e r P r o v i d e d M i d d l e w a r e \? w r a p p e d H a n d l e r : u n d e f i n e d / ) ;
153+ expect ( wrappedCode ) . toMatch ( / c o n s t p r o x y = u s e r P r o v i d e d P r o x y \? w r a p p e d H a n d l e r : (?: u n d e f i n e d | v o i d 0 ) / ) ;
154+ expect ( wrappedCode ) . toMatch ( / c o n s t m i d d l e w a r e = u s e r P r o v i d e d M i d d l e w a r e \? w r a p p e d H a n d l e r : (?: u n d e f i n e d | v o i d 0 ) / ) ;
153155 } ) ;
154156
155157 it ( 'should export middleware when user exports named "middleware" export' , async ( ) => {
@@ -196,8 +198,8 @@ describe('wrappingLoader', () => {
196198 expect ( wrappedCode ) . toContain ( 'userProvidedProxy = false' ) ;
197199
198200 // Middleware should be wrapped, proxy should be undefined
199- expect ( wrappedCode ) . toMatch ( / c o n s t m i d d l e w a r e = u s e r P r o v i d e d M i d d l e w a r e \? w r a p p e d H a n d l e r : u n d e f i n e d / ) ;
200- expect ( wrappedCode ) . toMatch ( / c o n s t p r o x y = u s e r P r o v i d e d P r o x y \? w r a p p e d H a n d l e r : u n d e f i n e d / ) ;
201+ expect ( wrappedCode ) . toMatch ( / c o n s t m i d d l e w a r e = u s e r P r o v i d e d M i d d l e w a r e \? w r a p p e d H a n d l e r : (?: u n d e f i n e d | v o i d 0 ) / ) ;
202+ expect ( wrappedCode ) . toMatch ( / c o n s t p r o x y = u s e r P r o v i d e d P r o x y \? w r a p p e d H a n d l e r : (?: u n d e f i n e d | v o i d 0 ) / ) ;
201203 } ) ;
202204
203205 it ( 'should export undefined middleware/proxy when user only exports default' , async ( ) => {
@@ -245,8 +247,8 @@ describe('wrappingLoader', () => {
245247 expect ( wrappedCode ) . toContain ( 'userProvidedProxy = false' ) ;
246248
247249 // Both middleware and proxy should be undefined (conditionals evaluate to false)
248- expect ( wrappedCode ) . toMatch ( / c o n s t m i d d l e w a r e = u s e r P r o v i d e d M i d d l e w a r e \? w r a p p e d H a n d l e r : u n d e f i n e d / ) ;
249- expect ( wrappedCode ) . toMatch ( / c o n s t p r o x y = u s e r P r o v i d e d P r o x y \? w r a p p e d H a n d l e r : u n d e f i n e d / ) ;
250+ expect ( wrappedCode ) . toMatch ( / c o n s t m i d d l e w a r e = u s e r P r o v i d e d M i d d l e w a r e \? w r a p p e d H a n d l e r : (?: u n d e f i n e d | v o i d 0 ) / ) ;
251+ expect ( wrappedCode ) . toMatch ( / c o n s t p r o x y = u s e r P r o v i d e d P r o x y \? w r a p p e d H a n d l e r : (?: u n d e f i n e d | v o i d 0 ) / ) ;
250252 } ) ;
251253 } ) ;
252254
0 commit comments