File tree Expand file tree Collapse file tree 5 files changed +50
-16
lines changed
cart-checkout-validation/default/src
cart-transform/default/src
order-discounts/default/src
product-discounts/default/src
shipping-discounts/default/src Expand file tree Collapse file tree 5 files changed +50
-16
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ use super::*;
22use shopify_function:: { run_function_with_input, Result } ;
33
44#[ test]
5- fn test_result_contains_no_operations ( ) -> Result < ( ) > {
5+ fn test_result_contains_single_error_when_quantity_exceeds_one ( ) -> Result < ( ) > {
66 let result = run_function_with_input (
77 function,
88 r#"
@@ -17,12 +17,34 @@ fn test_result_contains_no_operations() -> Result<()> {
1717 }
1818 "# ,
1919 ) ?;
20- let mut errors = Vec :: new ( ) ;
21- errors. push ( FunctionError {
22- localized_message : "Not possible to order more than one of each" . to_owned ( ) ,
23- target : "cart" . to_owned ( ) ,
24- } ) ;
25- let expected = crate :: output:: FunctionResult { errors : errors } ;
20+ let expected = crate :: output:: FunctionResult {
21+ errors : vec ! [ FunctionError {
22+ localized_message: "Not possible to order more than one of each" . to_owned( ) ,
23+ target: "cart" . to_owned( ) ,
24+ } ] ,
25+ } ;
26+
27+ assert_eq ! ( result, expected) ;
28+ Ok ( ( ) )
29+ }
30+
31+ #[ test]
32+ fn test_result_contains_no_errors_when_quantity_is_one ( ) -> Result < ( ) > {
33+ let result = run_function_with_input (
34+ function,
35+ r#"
36+ {
37+ "cart": {
38+ "lines": [
39+ {
40+ "quantity": 1
41+ }
42+ ]
43+ }
44+ }
45+ "# ,
46+ ) ?;
47+ let expected = crate :: output:: FunctionResult { errors : vec ! [ ] } ;
2648
2749 assert_eq ! ( result, expected) ;
2850 Ok ( ( ) )
Original file line number Diff line number Diff line change @@ -3,15 +3,18 @@ use shopify_function::Result;
33
44use serde:: { Deserialize , Serialize } ;
55
6+ type URL = String ;
7+
68generate_types ! (
79 query_path = "./input.graphql" ,
810 schema_path = "./schema.graphql"
911) ;
1012
1113#[ shopify_function]
1214fn function ( input : input:: ResponseData ) -> Result < output:: FunctionResult > {
13-
14- let no_changes = output:: FunctionResult { operations : Some ( vec ! [ ] ) } ;
15+ let no_changes = output:: FunctionResult {
16+ operations : Some ( vec ! [ ] ) ,
17+ } ;
1518
1619 Ok ( no_changes)
17- }
20+ }
Original file line number Diff line number Diff line change @@ -13,8 +13,11 @@ fn test_result_contains_no_discounts() -> Result<()> {
1313 }
1414 "# ,
1515 ) ?;
16- let expected = 0 ;
16+ let expected = output:: FunctionResult {
17+ discounts : vec ! [ ] ,
18+ discount_application_strategy : output:: DiscountApplicationStrategy :: FIRST ,
19+ } ;
1720
18- assert_eq ! ( result. discounts . len ( ) , expected) ;
21+ assert_eq ! ( result, expected) ;
1922 Ok ( ( ) )
2023}
Original file line number Diff line number Diff line change @@ -13,8 +13,11 @@ fn test_result_contains_no_discounts() -> Result<()> {
1313 }
1414 "# ,
1515 ) ?;
16- let expected = 0 ;
16+ let expected = output:: FunctionResult {
17+ discounts : vec ! [ ] ,
18+ discount_application_strategy : output:: DiscountApplicationStrategy :: FIRST ,
19+ } ;
1720
18- assert_eq ! ( result. discounts . len ( ) , expected) ;
21+ assert_eq ! ( result, expected) ;
1922 Ok ( ( ) )
2023}
Original file line number Diff line number Diff line change @@ -13,8 +13,11 @@ fn test_result_contains_no_discounts() -> Result<()> {
1313 }
1414 "# ,
1515 ) ?;
16- let expected = 0 ;
16+ let expected = output:: FunctionResult {
17+ discounts : vec ! [ ] ,
18+ discount_application_strategy : output:: DiscountApplicationStrategy :: FIRST ,
19+ } ;
1720
18- assert_eq ! ( result. discounts . len ( ) , expected) ;
21+ assert_eq ! ( result, expected) ;
1922 Ok ( ( ) )
2023}
You can’t perform that action at this time.
0 commit comments