Lines
100 %
Functions
Branches
use forms::{Action, Field, Form, FormValues, Kind, TRANSACTION_EDIT};
use super::row;
use crate::forms::copy_carried;
const CELLS: &[Field] = &[Field {
key: "name",
label: "Name",
kind: Kind::Text {
multiline: false,
suggest: None,
},
required: false,
}];
const PLAIN: Form = Form {
name: "test-plain",
title: "Plain",
fields: &[Field {
key: "tags",
label: "Tags",
kind: Kind::Rows {
fields: CELLS,
nested_under: None,
}],
action: Action::Mutation,
};
fn tagged() -> FormValues {
let mut values = FormValues::default();
values.push_row("tags", row(&[("name", "trip")]));
values
}
#[test]
fn a_form_without_carried_fields_copies_nothing() {
let mut to = FormValues::default();
copy_carried(&PLAIN, &tagged(), &mut to);
assert_eq!(to.rows("tags"), None);
fn only_the_split_tags_are_carried_by_the_transaction_form() {
let mut from = tagged();
from.push_row("split-tags", row(&[("row", "r1"), ("name", "memo")]));
to.push_row("splits", row(&[("key", "r1")]));
copy_carried(&TRANSACTION_EDIT, &from, &mut to);
assert_eq!(to.rows("split-tags"), from.rows("split-tags"));