1
use super::*;
2

            
3
#[test]
4
2
fn markup_in_a_message_is_escaped() {
5
2
    let html = escaped("<img src=x onerror=1>").expect("renders");
6
2
    assert!(!html.contains("<img"), "{html}");
7
2
    assert!(html.contains("&#60;img"), "{html}");
8
2
}
9

            
10
#[test]
11
2
fn a_plain_message_is_unchanged() {
12
2
    assert_eq!(
13
2
        escaped("Config saved: theme").expect("renders"),
14
2
        "Config saved: theme"
15
    );
16
2
}
17

            
18
#[tokio::test]
19
2
async fn a_reply_is_the_escaped_message() {
20
2
    let response = reply("<b>").expect("renders");
21
2
    assert_eq!(response.status(), axum::http::StatusCode::OK);
22
2
    let body = axum::body::to_bytes(response.into_body(), 1024)
23
2
        .await
24
2
        .expect("body");
25
2
    assert_eq!(&body[..], b"&#60;b&#62;");
26
2
}