wip: currently rewriting the project as a full stack application tangled.org/kacaii.dev/sigo
gleam
at main 25 lines 772 B view raw
1import app/http_router 2import app_test 3import gleam/dynamic/decode 4import gleam/http 5import gleam/json 6import wisp/simulate 7 8pub fn dashboard_stats_test() { 9 use ctx <- app_test.global_data() 10 11 let req = simulate.browser_request(http.Get, "/dashboard/stats") 12 let resp = http_router.handle_request(req, ctx) 13 assert resp.status == 200 as "Response status should be 200" 14 15 let body = simulate.read_body(resp) 16 let assert Ok(_) = 17 json.parse(body, { 18 use _ <- decode.field("totalOcorrencias", decode.int) 19 use _ <- decode.field("ocorrenciasHoje", decode.int) 20 use _ <- decode.field("emAndamento", decode.int) 21 use _ <- decode.field("equipesAtivas", decode.int) 22 decode.success(Nil) 23 }) 24 as "Response should contain valid JSON data" 25}