1
use super::*;
2

            
3
2
async fn body_of(response: Response) -> String {
4
2
    let bytes = axum::body::to_bytes(response.into_body(), usize::MAX)
5
2
        .await
6
        .unwrap_or_default();
7
2
    String::from_utf8_lossy(&bytes).into_owned()
8
2
}
9

            
10
#[tokio::test]
11
2
async fn the_result_names_both_accounts_and_offers_no_merge() {
12
2
    let done = Merged {
13
2
        into: uuid::Uuid::from_u128(1),
14
2
        from: uuid::Uuid::from_u128(2),
15
2
        moved: 2,
16
2
    };
17
2
    let response = merged(done, &References::default());
18
2
    assert_eq!(
19
2
        response
20
2
            .headers()
21
2
            .get("hx-retarget")
22
2
            .map(HeaderValue::as_bytes),
23
2
        Some(b"#nf-account-merge".as_slice())
24
    );
25
2
    let html = body_of(response).await;
26
2
    assert!(html.contains("2 splits moved"), "{html}");
27
2
    assert!(
28
2
        html.contains(&uuid::Uuid::from_u128(1).to_string()),
29
        "{html}"
30
    );
31
2
    assert!(
32
2
        html.contains(&uuid::Uuid::from_u128(2).to_string()),
33
        "{html}"
34
    );
35
2
    assert!(!html.contains("<button"), "{html}");
36
2
    assert!(html.contains("href=\"/account/merge\""), "{html}");
37
2
    assert!(html.contains("href=\"/account/list\""), "{html}");
38
2
}