Skip to content

Commit

Permalink
Add an unit test to verify SearchResultType string conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
crazytonyli committed Jan 16, 2025
1 parent 0f7a44d commit 231fa09
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions wp_api/src/search_results.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,19 @@ pub struct SparseSearchResult {
#[WpContextualOption]
pub object_subtype: Option<SearchResultSubtype>,
}

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

#[rstest]
#[case(SearchResultType::Post)]
#[case(SearchResultType::Term)]
#[case(SearchResultType::PostFormat)]
#[case(SearchResultType::Custom("foo_bar".to_string()))]
#[case(SearchResultType::Custom("foo-bar".to_string()))]
fn test_search_result_type_string_conversion(#[case] value: SearchResultType) {
assert_eq!(value, value.to_string().parse().unwrap());
}
}

0 comments on commit 231fa09

Please sign in to comment.