From add26b5690cda39f8e591205ba022690d2c1a33c Mon Sep 17 00:00:00 2001 From: marioEinsis Date: Tue, 27 Feb 2024 20:56:29 -0800 Subject: [PATCH] Add more cases for customers --- src/graphql/customer.rs | 48 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/src/graphql/customer.rs b/src/graphql/customer.rs index 944c146c..3f89df17 100644 --- a/src/graphql/customer.rs +++ b/src/graphql/customer.rs @@ -679,7 +679,53 @@ mod tests { assert_eq!(res.data.to_string(), r#"{insertCustomer: "9"}"#); let res = schema - .execute(r#"{customerList(last:10){edges{node{name}}totalCount}}"#) + .execute(r#"{customerList(last: 10){edges{node{name}}totalCount}}"#) + .await; + assert_eq!( + res.data.to_string(), + r#"{customerList: {edges: [{node: {name: "t1"}},{node: {name: "t10"}},{node: {name: "t2"}},{node: {name: "t3"}},{node: {name: "t4"}},{node: {name: "t5"}},{node: {name: "t6"}},{node: {name: "t7"}},{node: {name: "t8"}},{node: {name: "t9"}}],totalCount: 10}}"# + ); + + let res = schema + .execute(r#"{customerList(last: 10, before: "dDg="){edges{node{name}}totalCount,pageInfo{startCursor}}}"#) + .await; + assert_eq!( + res.data.to_string(), + r#"{customerList: {edges: [{node: {name: "t1"}},{node: {name: "t10"}},{node: {name: "t2"}},{node: {name: "t3"}},{node: {name: "t4"}},{node: {name: "t5"}},{node: {name: "t6"}},{node: {name: "t7"}}],totalCount: 10,pageInfo: {startCursor: "dDE="}}}"# + ); + + let res = schema + .execute( + r#"{customerList(last: 10, after: "dDc="){edges{node{name}}totalCount,pageInfo{startCursor}}}"#, + ) + .await; + assert_eq!( + res.data.to_string(), + r#"{customerList: {edges: [{node: {name: "t8"}},{node: {name: "t9"}}],totalCount: 10,pageInfo: {startCursor: "dDg="}}}"# + ); + + let res = schema + .execute( + r#"{customerList(first:10 after:"dDc=" ){edges{node{name}}totalCount,pageInfo{endCursor}}}"#, + ) + .await; + assert_eq!( + res.data.to_string(), + r#"{customerList: {edges: [{node: {name: "t8"}},{node: {name: "t9"}}],totalCount: 10,pageInfo: {endCursor: "dDk="}}}"# + ); + + let res = schema + .execute( + r#"{customerList(first:10 before:"dDc=" ){edges{node{name}}totalCount,pageInfo{endCursor}}}"#, + ) + .await; + assert_eq!( + res.data.to_string(), + r#"{customerList: {edges: [{node: {name: "t1"}},{node: {name: "t10"}},{node: {name: "t2"}},{node: {name: "t3"}},{node: {name: "t4"}},{node: {name: "t5"}},{node: {name: "t6"}}],totalCount: 10,pageInfo: {endCursor: "dDY="}}}"# + ); + + let res = schema + .execute(r#"{customerList(first:10){edges{node{name}}totalCount}}"#) .await; assert_eq!( res.data.to_string(),