Lines
100 %
Functions
Branches
//! A rows field the descriptor does not carry is an editable field.
use forms::{Action, Field, Form as Descriptor, Kind};
use crate::form::{Form, FormKind};
use crate::widgets::Widget;
const CELLS: &[Field] = &[Field {
key: "name",
label: "Name",
kind: Kind::Text {
multiline: false,
suggest: None,
},
required: false,
}];
const PLAIN: Descriptor = Descriptor {
name: "test-plain",
title: "Plain",
fields: &[Field {
key: "tags",
label: "Tags",
kind: Kind::Rows {
fields: CELLS,
nested_under: None,
}],
action: Action::Mutation,
};
#[test]
fn a_not_carried_tags_field_is_rendered() {
let form = Form::from_descriptor(&PLAIN, FormKind::AccountMerge);
let keys: Vec<_> = form.fields.iter().filter_map(|f| f.key).collect();
assert_eq!(keys, ["tags"]);
assert!(matches!(form.fields[0].widget, Widget::Rows(_)));
}