Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions tests/Giraffe.TokenRouter.Tests/TokenRouterTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,32 @@ let ``GET "/foo/blah blah/bar" returns "blah blah"`` () =
| Some ctx -> Assert.Equal(expected, getBody ctx)
}


[<Fact>]
let ``GET "/foo/tgz/test" returns "tgz"`` () =
let ctx = Substitute.For<HttpContext>()
let app =
router notFound [
GET [
route "/" => text "Hello World"
route "/foo" => text "bar"
routef "/foo/%s/%s/" (fun (operator, test) -> text (operator+" "+test))
]
]

ctx.Request.Method.ReturnsForAnyArgs "GET" |> ignore
ctx.Request.Path.ReturnsForAnyArgs (PathString("/foo/tgz/test/")) |> ignore
ctx.Response.Body <- new MemoryStream()
let expected = "tgz test"

task {
let! result = app next ctx

match result with
| None -> assertFailf "Result was expected to be %s" expected
| Some ctx -> Assert.Equal(expected, getBody ctx)
}

[<Fact>]
let ``GET "/foo/johndoe/59" returns "Name: johndoe, Age: 59"`` () =
let ctx = Substitute.For<HttpContext>()
Expand Down