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::*;
2
2
use shopify_function:: { run_function_with_input, Result } ;
3
3
4
4
#[ test]
5
- fn test_result_contains_no_operations ( ) -> Result < ( ) > {
5
+ fn test_result_contains_single_error_when_quantity_exceeds_one ( ) -> Result < ( ) > {
6
6
let result = run_function_with_input (
7
7
function,
8
8
r#"
@@ -17,12 +17,34 @@ fn test_result_contains_no_operations() -> Result<()> {
17
17
}
18
18
"# ,
19
19
) ?;
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 ! [ ] } ;
26
48
27
49
assert_eq ! ( result, expected) ;
28
50
Ok ( ( ) )
Original file line number Diff line number Diff line change @@ -3,15 +3,18 @@ use shopify_function::Result;
3
3
4
4
use serde:: { Deserialize , Serialize } ;
5
5
6
+ type URL = String ;
7
+
6
8
generate_types ! (
7
9
query_path = "./input.graphql" ,
8
10
schema_path = "./schema.graphql"
9
11
) ;
10
12
11
13
#[ shopify_function]
12
14
fn 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
+ } ;
15
18
16
19
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<()> {
13
13
}
14
14
"# ,
15
15
) ?;
16
- let expected = 0 ;
16
+ let expected = output:: FunctionResult {
17
+ discounts : vec ! [ ] ,
18
+ discount_application_strategy : output:: DiscountApplicationStrategy :: FIRST ,
19
+ } ;
17
20
18
- assert_eq ! ( result. discounts . len ( ) , expected) ;
21
+ assert_eq ! ( result, expected) ;
19
22
Ok ( ( ) )
20
23
}
Original file line number Diff line number Diff line change @@ -13,8 +13,11 @@ fn test_result_contains_no_discounts() -> Result<()> {
13
13
}
14
14
"# ,
15
15
) ?;
16
- let expected = 0 ;
16
+ let expected = output:: FunctionResult {
17
+ discounts : vec ! [ ] ,
18
+ discount_application_strategy : output:: DiscountApplicationStrategy :: FIRST ,
19
+ } ;
17
20
18
- assert_eq ! ( result. discounts . len ( ) , expected) ;
21
+ assert_eq ! ( result, expected) ;
19
22
Ok ( ( ) )
20
23
}
Original file line number Diff line number Diff line change @@ -13,8 +13,11 @@ fn test_result_contains_no_discounts() -> Result<()> {
13
13
}
14
14
"# ,
15
15
) ?;
16
- let expected = 0 ;
16
+ let expected = output:: FunctionResult {
17
+ discounts : vec ! [ ] ,
18
+ discount_application_strategy : output:: DiscountApplicationStrategy :: FIRST ,
19
+ } ;
17
20
18
- assert_eq ! ( result. discounts . len ( ) , expected) ;
21
+ assert_eq ! ( result, expected) ;
19
22
Ok ( ( ) )
20
23
}
You can’t perform that action at this time.
0 commit comments