Skip to content

Commit

Permalink
fix: add default calendar properties in From impl
Browse files Browse the repository at this point in the history
  • Loading branch information
hoodie committed Jan 1, 2023
1 parent eace465 commit ba44631
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/calendar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,24 @@ impl<C: Into<CalendarComponent>> FromIterator<C> for Calendar {
fn from_iter<T: IntoIterator<Item = C>>(iter: T) -> Self {
Calendar {
components: iter.into_iter().map(Into::into).collect(),
properties: Default::default(),
..Default::default()
}
}
}
#[test]
fn from_adds_default_properties() {
let todo = crate::Todo::default();
let cal = dbg!(Calendar::from([todo]));
assert!(cal.property_value("VERSION").is_some());
assert!(cal.property_value("CALSCALE").is_some());
assert!(cal.property_value("PRODID").is_some());

assert!(cal
.property_value("VERSION")
.and(cal.property_value("PRODID"))
.and(cal.property_value("CALSCALE"))
.is_some());
}

#[cfg(test)]
mod tests {
Expand Down

0 comments on commit ba44631

Please sign in to comment.