You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.3 KiB
64 lines
1.3 KiB
# shellcheck disable=SC2154,SC2034 |
|
|
|
it "Should match plain route" "$({ |
|
PATH_INFO='/plain/route' |
|
_exprash_init |
|
all '/plain/route' |
|
})" |
|
|
|
it "Should not match incorrect plain route" "$({ |
|
PATH_INFO='/plain/WRONG' |
|
_exprash_init |
|
! all '/plain/route' |
|
})" |
|
|
|
it "Should extract parameter" "$({ |
|
PATH_INFO='/cats/calico/pet' |
|
_exprash_init |
|
all '/cats/:cat/pet' && has_param 'cat' && [ "$(param 'cat')" == 'calico' ] |
|
})" |
|
|
|
it "Should match wildcard route" "$({ |
|
PATH_INFO='/cats/calico/pet' |
|
_exprash_init |
|
all '/cats/*/pet' |
|
})" |
|
|
|
it "Should not match incorrect wildcard route" "$({ |
|
PATH_INFO='/cats/calico/' |
|
_exprash_init |
|
! all '/cats/*/pet' |
|
})" |
|
|
|
it "Should match multi-wildcard route" "$({ |
|
PATH_INFO='/cats/calico/pet/donkey' |
|
_exprash_init |
|
all '/cats/**' |
|
})" |
|
|
|
it "Should not match incorrect multi-wildcard route" "$({ |
|
PATH_INFO='/INCORRECT/calico/pet/donkey' |
|
_exprash_init |
|
! all '/cats/**' |
|
})" |
|
|
|
it "Should not match path shorter than route" "$({ |
|
PATH_INFO='/year' |
|
_exprash_init |
|
! all '/year/:year' |
|
})" |
|
|
|
it "Should match get route" "$({ |
|
REQUEST_METHOD='GET' |
|
PATH_INFO='/simple/route' |
|
_exprash_init |
|
get '/simple/route' |
|
})" |
|
|
|
it "Should not match get route with incorrect method" "$({ |
|
REQUEST_METHOD='POST' |
|
PATH_INFO='/simple/route' |
|
_exprash_init |
|
! get '/simple/route' |
|
})" |
|
|
|
|