use loco_rs::testing::prelude::*;
use serial_test::serial;
use termi_api::app::App;

#[tokio::test]
#[serial]
async fn can_get_categories() {
    request::<App, _, _>(|request, ctx| async move {
        seed::<App>(&ctx).await.unwrap();

        let res = request.get("/api/categories/").await;
        assert_eq!(res.status_code(), 200);

        let body = res.text();
        assert!(body.contains("\"name\":\"tech\""));
        assert!(body.contains("\"count\":3"));
    })
    .await;
}
