use serde_json::json;
use super::{create, update};
#[test]
fn a_filing_carries_a_body_only_where_there_is_one() {
assert_eq!(
create(
"p".to_owned(),
"alba".to_owned(),
"a title".to_owned(),
Some("the body".to_owned()),
),
json!({
"op": "create", "project": "p", "name": "alba",
"title": "a title", "body": "the body",
})
);
assert_eq!(
create(
"p".to_owned(),
"alba".to_owned(),
"a title".to_owned(),
None
),
json!({ "op": "create", "project": "p", "name": "alba", "title": "a title" })
);
}
#[test]
fn an_amendment_carries_only_the_fields_that_were_typed() {
assert_eq!(
update(
"p".to_owned(),
"bl-1".to_owned(),
"alba".to_owned(),
None,
None,
Some("what happened".to_owned()),
),
json!({
"op": "update", "project": "p", "id": "bl-1", "name": "alba",
"note": "what happened",
})
);
assert_eq!(
update(
"p".to_owned(),
"bl-1".to_owned(),
"alba".to_owned(),
Some("t".to_owned()),
Some("b".to_owned()),
Some("n".to_owned()),
),
json!({
"op": "update", "project": "p", "id": "bl-1", "name": "alba",
"title": "t", "body": "b", "note": "n",
})
);
}
#[test]
fn an_amendment_of_nothing_is_the_bare_envelope() {
assert_eq!(
update(
"p".to_owned(),
"bl-1".to_owned(),
"alba".to_owned(),
None,
None,
None,
),
json!({ "op": "update", "project": "p", "id": "bl-1", "name": "alba" })
);
}