mirror of
https://github.com/robertwayne/axum-htmx
synced 2024-11-24 04:12:50 +01:00
Add a test for the double-escape bug
This commit is contained in:
parent
6c7ddeec19
commit
f406f74591
1 changed files with 25 additions and 0 deletions
|
@ -234,3 +234,28 @@ impl serde::Serialize for SwapOption {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use serde_json::json;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn valid_event_to_header_encoding() {
|
||||
let evt = HxEvent::new_with_data(
|
||||
"my-event",
|
||||
json!({"level": "info", "message": {
|
||||
"body": "This is a test message.",
|
||||
"title": "Hello, world!",
|
||||
}}),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let header_value = events_to_header_value(vec![evt]).unwrap();
|
||||
|
||||
let expected_value = r#"{"my-event":{"level":"info","message":{"body":"This is a test message.","title":"Hello, world!"}}}"#;
|
||||
|
||||
assert_eq!(header_value, HeaderValue::from_static(expected_value));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue