Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ mod checklist_type_option_tests {

let json_value = json!({
"options": [
{ "id": "1", "name": "Option1", "color": 0 },
{ "id": "2", "name": "Option2", "color": 1 }
{ "id": "1", "name": "Option1", "color": "Pink" },
{ "id": "2", "name": "Option2", "color": "LightPink" }
],
"selected_option_ids": ["1"]
});
Expand Down
32 changes: 31 additions & 1 deletion collab-database/src/fields/type_option/select_type_option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ impl SelectOption {
}
}
#[derive(PartialEq, Eq, Serialize, Deserialize, Debug, Clone)]
#[serde(try_from = "u8", into = "u8")]
#[repr(u8)]
#[derive(Default)]
pub enum SelectOptionColor {
Expand Down Expand Up @@ -553,4 +552,35 @@ mod tests {
let result = select_type_option.convert_raw_cell_data(&raw_data);
assert_eq!(result, "Option 1, Option 2");
}

#[test]
fn test_select_content_deser() {
let js_str = r#"{
"options": [
{
"id": "CEZD",
"name": "To Do",
"color": "Purple"
},
{
"id": "TznH",
"name": "Doing",
"color": "Orange"
},
{
"id": "__n6",
"name": "✅ Done",
"color": "Yellow"
}
],
"disable_color": false
}"#;

let select_ty_opt = serde_json::from_str::<SelectTypeOption>(js_str).unwrap();
assert_eq!(select_ty_opt.options.len(), 3);
assert_eq!(select_ty_opt.options[0].name, "To Do");
assert_eq!(select_ty_opt.options[1].color, SelectOptionColor::Orange);
assert_eq!(select_ty_opt.options[2].id, "__n6");
assert!(!select_ty_opt.disable_color);
}
}
Loading