diff options
| -rw-r--r-- | tests/Unit/RouterTest.php | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/tests/Unit/RouterTest.php b/tests/Unit/RouterTest.php index a2ed18f..a7e7a21 100644 --- a/tests/Unit/RouterTest.php +++ b/tests/Unit/RouterTest.php @@ -218,22 +218,6 @@ it('make a route with parameter', function () { ->parameters->toBe(['test1' => 'hello']); }); -it('makes a get route', function () { - $router = new Router(); - $router->get('/test1/test2', fn () => null); - - expect($router->findRoute(HttpMethod::Get, '/test1/test2')) - ->toBeInstanceOf(RouteMatch::class); -}); - -it('makes a post route', function () { - $router = new Router(); - $router->post('/test1/test2', fn () => null); - - expect($router->findRoute(HttpMethod::Post, '/test1/test2')) - ->toBeInstanceOf(RouteMatch::class); -}); - it('makes a :dataset route') ->with('http-methods') ->expect(function (HttpMethod $m) { @@ -244,6 +228,12 @@ it('makes a :dataset route') }) ->toBeInstanceOf(RouteMatch::class); +it('makes route with or without / prefix', function(string $path) { + $router = new Router; + $r = $router->get($path, fn() => null)->getRoute(); + expect($router->findRoute(HttpMethod::Get, '/test')?->route)->toBe($r); +})->with(['/test', 'test']); + it('returns RouteDefinition when making route') ->expect(fn () => (new Router()) ->make(HttpMethod::Get, '/test', fn () => null) |
