mirror of
https://github.com/nushell/nushell.git
synced 2024-11-29 20:03:54 +01:00
ab5e24a0e7
* Initial from-ical implementation * Initial from-vcard implementation * Rename from-ics and from-vcf for autoconvert * Remove redundant clones * Add from-vcf and from-ics tests Co-authored-by: Jonathan Turner <jonathandturner@users.noreply.github.com>
85 lines
2.4 KiB
Rust
85 lines
2.4 KiB
Rust
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
|
|
use nu_test_support::playground::Playground;
|
|
use nu_test_support::{nu, pipeline};
|
|
|
|
#[test]
|
|
fn infers_types() {
|
|
Playground::setup("filter_from_vcf_test_1", |dirs, sandbox| {
|
|
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
|
"contacts.vcf",
|
|
r#"
|
|
BEGIN:VCARD
|
|
VERSION:3.0
|
|
FN:John Doe
|
|
N:Doe;John;;;
|
|
EMAIL;TYPE=INTERNET:john.doe99@gmail.com
|
|
item1.ORG:'Alpine Ski Resort'
|
|
item1.X-ABLabel:Other
|
|
item2.TITLE:'Ski Instructor'
|
|
item2.X-ABLabel:Other
|
|
BDAY:19001106
|
|
NOTE:Facebook: john.doe.3\nWebsite: \nHometown: Cleveland\, Ohio
|
|
CATEGORIES:myContacts
|
|
END:VCARD
|
|
BEGIN:VCARD
|
|
VERSION:3.0
|
|
FN:Alex Smith
|
|
N:Smith;Alex;;;
|
|
TEL;TYPE=CELL:(890) 123-4567
|
|
CATEGORIES:Band,myContacts
|
|
END:VCARD
|
|
"#,
|
|
)]);
|
|
|
|
let actual = nu!(
|
|
cwd: dirs.test(), pipeline(
|
|
r#"
|
|
open contacts.vcf
|
|
| count
|
|
| echo $it
|
|
"#
|
|
));
|
|
|
|
assert_eq!(actual, "2");
|
|
})
|
|
}
|
|
|
|
#[test]
|
|
fn from_vcf_text_to_table() {
|
|
Playground::setup("filter_from_vcf_test_2", |dirs, sandbox| {
|
|
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
|
"contacts.txt",
|
|
r#"
|
|
BEGIN:VCARD
|
|
VERSION:3.0
|
|
FN:John Doe
|
|
N:Doe;John;;;
|
|
EMAIL;TYPE=INTERNET:john.doe99@gmail.com
|
|
item1.ORG:'Alpine Ski Resort'
|
|
item1.X-ABLabel:Other
|
|
item2.TITLE:'Ski Instructor'
|
|
item2.X-ABLabel:Other
|
|
BDAY:19001106
|
|
NOTE:Facebook: john.doe.3\nWebsite: \nHometown: Cleveland\, Ohio
|
|
CATEGORIES:myContacts
|
|
END:VCARD
|
|
"#,
|
|
)]);
|
|
|
|
let actual = nu!(
|
|
cwd: dirs.test(), pipeline(
|
|
r#"
|
|
open contacts.txt
|
|
| from-vcf
|
|
| get properties
|
|
| where name == "EMAIL"
|
|
| first
|
|
| get value
|
|
| echo $it
|
|
"#
|
|
));
|
|
|
|
assert_eq!(actual, "john.doe99@gmail.com");
|
|
})
|
|
}
|