@@ -120,43 +120,57 @@ describe('error', () => {
120120 expect ( response . status ) . toBe ( 500 )
121121 } )
122122
123- it ( 'return correct number status on error function' , async ( ) => {
124- const app = new Elysia ( ) . get ( '/' , ( { error } ) =>
125- error ( 418 , 'I am a teapot' )
126- )
123+ it . each ( [ true , false ] ) (
124+ 'return correct number status on error function with aot: %p' ,
125+ async ( aot ) => {
126+ const app = new Elysia ( { aot } ) . get ( '/' , ( { error } ) =>
127+ error ( 418 , 'I am a teapot' )
128+ )
127129
128- const response = await app . handle ( req ( '/' ) )
130+ const response = await app . handle ( req ( '/' ) )
129131
130- expect ( response . status ) . toBe ( 418 )
131- } )
132+ expect ( response . status ) . toBe ( 418 )
133+ }
134+ )
132135
133- it ( 'return correct named status on error function' , async ( ) => {
134- const app = new Elysia ( ) . get ( '/' , ( { error } ) =>
135- error ( "I'm a teapot" , 'I am a teapot' )
136- )
136+ it . each ( [ true , false ] ) (
137+ 'return correct named status on error function with aot: %p' ,
138+ async ( aot ) => {
139+ const app = new Elysia ( { aot } ) . get ( '/' , ( { error } ) =>
140+ error ( "I'm a teapot" , 'I am a teapot' )
141+ )
137142
138- const response = await app . handle ( req ( '/' ) )
143+ const response = await app . handle ( req ( '/' ) )
139144
140- expect ( response . status ) . toBe ( 418 )
141- } )
145+ expect ( response . status ) . toBe ( 418 )
146+ }
147+ )
142148
143- it ( 'return correct number status without value on error function' , async ( ) => {
144- const app = new Elysia ( ) . get ( '/' , ( { error } ) => error ( 418 ) )
149+ it . each ( [ true , false ] ) (
150+ 'return correct number status without value on error function with aot: %p' ,
151+ async ( aot ) => {
152+ const app = new Elysia ( { aot } ) . get ( '/' , ( { error } ) => error ( 418 ) )
145153
146- const response = await app . handle ( req ( '/' ) )
154+ const response = await app . handle ( req ( '/' ) )
147155
148- expect ( response . status ) . toBe ( 418 )
149- expect ( await response . text ( ) ) . toBe ( "I'm a teapot" )
150- } )
156+ expect ( response . status ) . toBe ( 418 )
157+ expect ( await response . text ( ) ) . toBe ( "I'm a teapot" )
158+ }
159+ )
151160
152- it ( 'return correct named status without value on error function' , async ( ) => {
153- const app = new Elysia ( ) . get ( '/' , ( { error } ) => error ( "I'm a teapot" ) )
161+ it . each ( [ true , false ] ) (
162+ 'return correct named status without value on error function with aot: %p' ,
163+ async ( aot ) => {
164+ const app = new Elysia ( { aot } ) . get ( '/' , ( { error } ) =>
165+ error ( "I'm a teapot" )
166+ )
154167
155- const response = await app . handle ( req ( '/' ) )
168+ const response = await app . handle ( req ( '/' ) )
156169
157- expect ( response . status ) . toBe ( 418 )
158- expect ( await response . text ( ) ) . toBe ( "I'm a teapot" )
159- } )
170+ expect ( response . status ) . toBe ( 418 )
171+ expect ( await response . text ( ) ) . toBe ( "I'm a teapot" )
172+ }
173+ )
160174
161175 it ( 'handle error in order' , async ( ) => {
162176 let order = < string [ ] > [ ]
0 commit comments