@@ -58,7 +58,7 @@ tape('tiny::internals', (t) => {
58
58
} ) ;
59
59
60
60
tape ( 'tiny::usage::basic' , ( t ) => {
61
- t . plan ( 1 ) ;
61
+ t . plan ( 3 ) ;
62
62
63
63
const app = tiny ( ) ;
64
64
const arr = [ [ 'GET' , '/' ] , [ 'POST' , '/users' ] , [ 'PUT' , '/users/:id' ] ] ;
@@ -161,7 +161,7 @@ tape('tiny::usage::variadic', async (t) => {
161
161
} ) ;
162
162
163
163
tape ( 'tiny::usage::middleware' , async ( t ) => {
164
- t . plan ( 21 ) ;
164
+ t . plan ( 20 ) ;
165
165
166
166
const app = tiny ( )
167
167
. filter ( ( req , res , next ) => {
@@ -171,16 +171,27 @@ tape('tiny::usage::middleware', async (t) => {
171
171
( req . two = 'world' ) && next ( ) ;
172
172
} )
173
173
. filter ( '/about' , ( req , res , next ) => {
174
- t . is ( req . one , 'hello' , '~> sub-mware runs after first global middleware' ) ;
175
- t . is ( req . two , 'world' , '~> sub-mware runs after second global middleware' ) ;
176
- res . end ( 'About' ) ;
174
+ t . is ( req . one , 'hello' , '~> sub-mware [/about] runs after first global middleware' ) ;
175
+ t . is ( req . two , 'world' , '~> sub-mware [/about] runs after second global middleware' ) ;
176
+ next ( ) ;
177
177
} )
178
178
. filter ( '/subgroup' , ( req , res , next ) => {
179
179
req . subgroup = true ;
180
- t . is ( req . one , 'hello' , '~> sub-mware runs after first global middleware' ) ;
181
- t . is ( req . two , 'world' , '~> sub-mware runs after second global middleware' ) ;
180
+ t . is (
181
+ req . one ,
182
+ 'hello' ,
183
+ '~> sub-mware [/subgroup] runs after first global middleware'
184
+ ) ;
185
+ t . is (
186
+ req . two ,
187
+ 'world' ,
188
+ '~> sub-mware [/subgroup] runs after second global middleware'
189
+ ) ;
182
190
next ( ) ;
183
191
} )
192
+ . get ( '/about' , ( req , res ) => {
193
+ res . end ( 'About' ) ;
194
+ } )
184
195
. post ( '/subgroup' , ( req , res ) => {
185
196
t . is ( req . subgroup , true , '~~> POST /subgroup ran after its shared middleware' ) ;
186
197
res . end ( 'POST /subgroup' ) ;
@@ -222,7 +233,7 @@ tape('tiny::usage::middleware', async (t) => {
222
233
} ) ;
223
234
224
235
tape ( 'tiny::usage::middleware (async)' , async ( t ) => {
225
- t . plan ( 7 ) ;
236
+ t . plan ( 6 ) ;
226
237
227
238
const app = tiny ( )
228
239
. filter ( ( req , res , next ) => {
@@ -247,8 +258,6 @@ tape('tiny::usage::middleware (async)', async (t) => {
247
258
res . end ( 'Hello' ) ;
248
259
} ) ;
249
260
250
- t . is ( app . wares . length , 2 , 'added 2 middleware functions' ) ;
251
-
252
261
app . build ( ) ;
253
262
app . listen ( 8080 , 'localhost' ) ;
254
263
const uri = 'http://localhost:8080' ;
@@ -262,7 +271,7 @@ tape('tiny::usage::middleware (async)', async (t) => {
262
271
} ) ;
263
272
264
273
tape ( 'tiny::usage::middleware (basenames)' , async ( t ) => {
265
- t . plan ( 40 ) ;
274
+ t . plan ( 37 ) ;
266
275
267
276
let chk = false ;
268
277
const aaa = ( req , res , next ) => ( ( req . aaa = 'aaa' ) , next ( ) ) ;
@@ -317,15 +326,6 @@ tape('tiny::usage::middleware (basenames)', async (t) => {
317
326
res . end ( 'hello from main' ) ;
318
327
} ) ;
319
328
320
- t . is ( app . wares . length , 3 , 'added 3 global middleware functions' ) ;
321
- const keys = Object . keys ( app . bwares ) ;
322
- t . is ( keys . length , 2 , 'added 2 basename middleware groups' ) ;
323
- t . deepEqual (
324
- keys ,
325
- [ '/foo' , '/bar' ] ,
326
- '~> has middleware groups for `/foo` & `/bar` path matches'
327
- ) ;
328
-
329
329
app . build ( ) ;
330
330
app . listen ( 8080 , 'localhost' ) ;
331
331
const uri = 'http://localhost:8080' ;
@@ -381,7 +381,7 @@ tape('tiny::usage::middleware (wildcard)', async (t) => {
381
381
) ;
382
382
res . end ( 'hello from bar' ) ;
383
383
} )
384
- . get ( '*' , ( req , res ) => {
384
+ . get ( '*all ' , ( req , res ) => {
385
385
// runs 3x
386
386
t . pass ( 'runs the MAIN app handler for GET /*' ) ;
387
387
t . is ( req . foo , 'foo' , '~> runs after `foo` global middleware' ) ;
0 commit comments