1
0
mirror of https://github.com/pcvolkmer/osc-variant.git synced 2025-04-19 19:56:50 +00:00

feat: add form field default value to profile

This commit is contained in:
Paul-Christian Volkmer 2024-03-18 14:41:48 +01:00
parent 837ed105fa
commit 4270b99f76

View File

@ -88,6 +88,7 @@ pub struct FormField {
pub name: String,
#[serde(default)]
pub hide: bool,
pub default_value: Option<String>
}
#[derive(Deserialize)]
@ -263,4 +264,24 @@ mod tests {
Err(e) => panic!("Cannot deserialize profile: {}", e),
}
}
#[test]
fn should_deserialize_form_fields_with_default_value() {
let content = "forms:
- name: 'DNPM Therapieplan'
form_fields:
- name: formularfeld_to_keep
default_value: 'X'
";
match Profile::from_str(content) {
Ok(profile) => {
assert_eq!(profile.forms.len(), 1);
assert_eq!(profile.forms[0].name, "DNPM Therapieplan");
assert_eq!(profile.forms[0].form_fields[0].name, "formularfeld_to_keep");
assert_eq!(profile.forms[0].form_fields[0].default_value, Some("X".to_string()));
}
Err(e) => panic!("Cannot deserialize profile: {}", e),
}
}
}