Add test for multiple flatten attribute of InputObject.
This commit is contained in:
parent
d2299f0a6d
commit
b4997e4b27
|
@ -105,7 +105,7 @@ pub async fn test_inputobject_derive_and_item_attributes() {
|
|||
}
|
||||
|
||||
#[async_std::test]
|
||||
pub async fn test_inputobject_flatten() {
|
||||
pub async fn test_inputobject_flatten_recursive() {
|
||||
#[derive(GQLInputObject, Debug, Eq, PartialEq)]
|
||||
struct A {
|
||||
a: i32,
|
||||
|
@ -231,3 +231,65 @@ pub async fn test_inputobject_flatten() {
|
|||
})
|
||||
);
|
||||
}
|
||||
|
||||
#[async_std::test]
|
||||
pub async fn test_inputobject_flatten_multiple() {
|
||||
#[derive(GQLInputObject, Debug, Eq, PartialEq)]
|
||||
struct A {
|
||||
a: i32,
|
||||
}
|
||||
|
||||
#[derive(GQLInputObject, Debug, Eq, PartialEq)]
|
||||
struct B {
|
||||
b: i32,
|
||||
}
|
||||
|
||||
#[derive(GQLInputObject, Debug, Eq, PartialEq)]
|
||||
struct C {
|
||||
c: i32,
|
||||
}
|
||||
|
||||
#[derive(GQLInputObject, Debug, Eq, PartialEq)]
|
||||
struct ABC {
|
||||
#[field(flatten)]
|
||||
a: A,
|
||||
|
||||
#[field(flatten)]
|
||||
b: B,
|
||||
|
||||
#[field(flatten)]
|
||||
c: C,
|
||||
}
|
||||
|
||||
assert_eq!(
|
||||
ABC::parse(Some(
|
||||
serde_json::json!({
|
||||
"a": 10,
|
||||
"b": 20,
|
||||
"c": 30,
|
||||
})
|
||||
.into()
|
||||
))
|
||||
.unwrap(),
|
||||
ABC {
|
||||
a: A { a: 10 },
|
||||
b: B { b: 20 },
|
||||
c: C { c: 30 }
|
||||
}
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
ABC {
|
||||
a: A { a: 10 },
|
||||
b: B { b: 20 },
|
||||
c: C { c: 30 }
|
||||
}
|
||||
.to_value(),
|
||||
serde_json::json!({
|
||||
"a": 10,
|
||||
"b": 20,
|
||||
"c": 30,
|
||||
})
|
||||
.into()
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user