Skip to content

Commit a8ee38d

Browse files
committed
Implement pattern
1 parent f94133d commit a8ee38d

File tree

1 file changed

+27
-75
lines changed

1 file changed

+27
-75
lines changed

tests/pattern_tests_meta.rs

Lines changed: 27 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -512,81 +512,33 @@ fn test_search_pattern_credential() {
512512
.trim();
513513
assert_actual_expected!(format_paths(&found_elements), expected);
514514

515-
// The above pattern is returning some text elements more than once.
516-
//
517-
// Current actual output:
518-
519-
/*
520-
9e3bff3a "certificateNumber"
521-
21c21808 "123-456-789"
522-
6e5d379f "expirationDate"
523-
5f82a16a "lastName"
524-
fe4d5230 "Maxwell"
525-
222afe69 "issueDate"
526-
051beee6 "Certificate of Completion"
527-
3976ef74 "photo"
528-
231b8527 "This is James Maxwell's photo."
529-
f13aa855 "professionalDevelopmentHours"
530-
4395643b "firstName"
531-
d6d0b768 "James"
532-
e6bf4dd3 "topics"
533-
2b191589 "continuingEducationUnits"
534-
f8489ac1 "Example Electrical Engineering Board"
535-
8e4e62eb "subject"
536-
202c10ef "RF and Microwave Engineering"
537-
f8489ac1 "Example Electrical Engineering Board"
538-
f106bad1 "Signed by Example Electrical Engineering Board"
539-
9e3bff3a "certificateNumber"
540-
21c21808 "123-456-789"
541-
6e5d379f "expirationDate"
542-
5f82a16a "lastName"
543-
fe4d5230 "Maxwell"
544-
222afe69 "issueDate"
545-
051beee6 "Certificate of Completion"
546-
3976ef74 "photo"
547-
231b8527 "This is James Maxwell's photo."
548-
f13aa855 "professionalDevelopmentHours"
549-
4395643b "firstName"
550-
d6d0b768 "James"
551-
e6bf4dd3 "topics"
552-
2b191589 "continuingEducationUnits"
553-
f8489ac1 "Example Electrical Engineering Board"
554-
8e4e62eb "subject"
555-
202c10ef "RF and Microwave Engineering"
556-
f8489ac1 "Example Electrical Engineering Board"
557-
*/
558-
}
559-
560-
#[test]
561-
#[ignore]
562-
fn test_search_pattern_credential_2() {
563-
// // A pattern that searches for the text "James" in the credential
564-
// let james_search_pattern = Pattern::search(Pattern::text("James"));
565-
// // Search for specific strings that should be in the credential
566-
// let james_paths = james_search_pattern.paths(&cred);
567-
// assert_eq!(james_paths.len(), 1);
568-
569-
// // A pattern that searches for the text "Maxwell" in the credential
570-
// let maxwell_search_pattern = Pattern::search(Pattern::text("Maxwell"));
571-
// let maxwell_paths = maxwell_search_pattern.paths(&cred);
572-
// assert_eq!(maxwell_paths.len(), 1);
573-
574-
// // A pattern that searches for numbers in the credential
575-
// let number_search_pattern =
576-
// Pattern::search(Pattern::assertion_with_object(Pattern::any_number()));
577-
// // Should find education units and hours
578-
// let number_paths = number_search_pattern.paths(&cred);
579-
// // Get the last element of each path as a single-element path for output
580-
// let number_paths: Vec<Path> = number_paths
581-
// .iter()
582-
// .map(|path| vec![(*path.last().unwrap()).clone()])
583-
// .collect();
584-
// let expected = indoc! {r#"
585-
// 54b3e1e7 "professionalDevelopmentHours": 15
586-
// 8ec5e912 "continuingEducationUnits": 1
587-
// "#}
588-
// .trim();
589-
// assert_actual_expected!(format_paths(&number_paths), expected);
515+
// A pattern that searches for the text "James" in the credential
516+
let james_search_pattern = Pattern::search(Pattern::text("James"));
517+
// Search for specific strings that should be in the credential
518+
let james_paths = james_search_pattern.paths(&cred);
519+
assert_eq!(james_paths.len(), 1);
520+
521+
// A pattern that searches for the text "Maxwell" in the credential
522+
let maxwell_search_pattern = Pattern::search(Pattern::text("Maxwell"));
523+
let maxwell_paths = maxwell_search_pattern.paths(&cred);
524+
assert_eq!(maxwell_paths.len(), 1);
525+
526+
// A pattern that searches for numbers in the credential
527+
let number_search_pattern =
528+
Pattern::search(Pattern::assertion_with_object(Pattern::any_number()));
529+
// Should find education units and hours
530+
let number_paths = number_search_pattern.paths(&cred);
531+
// Get the last element of each path as a single-element path for output
532+
let number_paths: Vec<Path> = number_paths
533+
.iter()
534+
.map(|path| vec![(*path.last().unwrap()).clone()])
535+
.collect();
536+
let expected = indoc! {r#"
537+
54b3e1e7 "professionalDevelopmentHours": 15
538+
8ec5e912 "continuingEducationUnits": 1
539+
"#}
540+
.trim();
541+
assert_actual_expected!(format_paths(&number_paths), expected);
590542
}
591543

592544
#[test]

0 commit comments

Comments
 (0)