Skip to content

Commit

Permalink
add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Oct 4, 2024
1 parent 0e67fa3 commit 534c100
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions crates/next-core/src/next_manifests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,3 +308,39 @@ pub struct ClientBuildManifest<'a> {
#[serde(flatten)]
pub pages: HashMap<RcStr, Vec<&'a str>>,
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_middleware_matcher_serialization() {
let matchers = vec![
MiddlewareMatcher {
regexp: None,
locale: false,
has: None,
missing: None,
original_source: "".into(),
},
MiddlewareMatcher {
regexp: Some(".*".into()),
locale: true,
has: Some(vec![RouteHas::Query {
key: "foo".into(),
value: None,
}]),
missing: Some(vec![RouteHas::Query {
key: "bar".into(),
value: Some("value".into()),
}]),
original_source: "source".into(),
},
];

let serialized = serde_json::to_string(&matchers).unwrap();
let deserialized: Vec<MiddlewareMatcher> = serde_json::from_str(&serialized).unwrap();

assert_eq!(matchers, deserialized);
}
}

0 comments on commit 534c100

Please sign in to comment.