test: UnitTest Switching from Multi to text (#1585)

This commit is contained in:
Kelvin 2022-12-20 20:33:17 +08:00 committed by GitHub
parent ce86227da3
commit 45c73a20c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -43,4 +43,37 @@ mod tests {
done_option.name,
);
}
/*
- [Unit Test] Testing the switching from Multi-selection type to Text type
- Tracking : https://github.com/AppFlowy-IO/AppFlowy/issues/1183
*/
#[test]
fn multiselect_to_text_type() {
let text_type_option = RichTextTypeOptionPB::default();
let field_type = FieldType::MultiSelect;
let France = SelectOptionPB::new("France");
let france_optionId = France.id.clone();
let Argentina = SelectOptionPB::new("Argentina");
let argentina_optionId = Argentina.id.clone();
let multi_select = MultiSelectTypeOptionBuilder::default()
.add_option(France.clone())
.add_option(Argentina.clone());
let field_rev = FieldBuilder::new(multi_select).build();
assert_eq!(
text_type_option
.decode_cell_data(
format!("{},{}", france_optionId, argentina_optionId),
&field_type,
&field_rev
)
.unwrap()
.to_string(),
format!("{},{}", France.name, Argentina.name)
);
}
}