Skip to content

Commit

Permalink
Add more cases for customers
Browse files Browse the repository at this point in the history
  • Loading branch information
marioCluml committed Feb 28, 2024
1 parent d9a19a1 commit add26b5
Showing 1 changed file with 47 additions and 1 deletion.
48 changes: 47 additions & 1 deletion src/graphql/customer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit add26b5

Please sign in to comment.