@@ -7,21 +7,21 @@ fn test_discount_with_no_configuration() -> Result<()> {
7
7
function,
8
8
r#"
9
9
{
10
- "cart": {
11
- "lines": [
12
- {
13
- "quantity": 5,
14
- "merchandise": {
15
- "__typename": "ProductVariant",
16
- "id": "gid://shopify/ProductVariant/0"
17
- }
10
+ "cart": {
11
+ "lines": [
12
+ {
13
+ "quantity": 5,
14
+ "merchandise": {
15
+ "__typename": "ProductVariant",
16
+ "id": "gid://shopify/ProductVariant/0"
18
17
}
19
- ]
20
- },
21
- "discountNode": {
22
- "metafield ": null
23
- }
18
+ }
19
+ ]
20
+ },
21
+ "discountNode ": {
22
+ "metafield": null
24
23
}
24
+ }
25
25
"# ,
26
26
) ?;
27
27
let expected = 0 ;
@@ -36,39 +36,55 @@ fn test_discount_with_configuration() -> Result<()> {
36
36
function,
37
37
r#"
38
38
{
39
- "cart": {
40
- "lines": [
41
- {
42
- "quantity": 5,
43
- "merchandise": {
44
- "__typename": "ProductVariant",
45
- "id": "gid://shopify/ProductVariant/0"
46
- }
47
- },
48
- {
49
- "quantity": 1,
50
- "merchandise": {
51
- "__typename": "ProductVariant",
52
- "id": "gid://shopify/ProductVariant/1"
53
- }
39
+ "cart": {
40
+ "lines": [
41
+ {
42
+ "quantity": 5,
43
+ "merchandise": {
44
+ "__typename": "ProductVariant",
45
+ "id": "gid://shopify/ProductVariant/0"
46
+ }
47
+ },
48
+ {
49
+ "quantity": 1,
50
+ "merchandise": {
51
+ "__typename": "ProductVariant",
52
+ "id": "gid://shopify/ProductVariant/1"
54
53
}
55
- ]
56
- },
57
- "discountNode": {
58
- "metafield": {
59
- "value": "{\"quantity\":5,\"percentage\":10.0}"
60
54
}
55
+ ]
56
+ },
57
+ "discountNode": {
58
+ "metafield": {
59
+ "value": "{\"quantity\":5,\"percentage\":10.0}"
61
60
}
62
61
}
62
+ }
63
63
"# ,
64
64
) ?;
65
- let expected = output:: Target {
66
- product_variant : Some ( output:: ProductVariantTarget {
67
- id : "gid://shopify/ProductVariant/0" . to_string ( ) ,
68
- quantity : None
69
- } )
65
+ let expected = output:: FunctionResult {
66
+ discount_application_strategy : output:: DiscountApplicationStrategy :: FIRST ,
67
+ discounts : vec ! [
68
+ output:: Discount {
69
+ message: None ,
70
+ value: output:: Value {
71
+ fixed_amount: None ,
72
+ percentage: Some ( output:: Percentage {
73
+ value: "10" . to_string( )
74
+ } )
75
+ } ,
76
+ targets: vec![
77
+ output:: Target {
78
+ product_variant: Some ( output:: ProductVariantTarget {
79
+ id: "gid://shopify/ProductVariant/0" . to_string( ) ,
80
+ quantity: None
81
+ } )
82
+ }
83
+ ]
84
+ }
85
+ ]
70
86
} ;
71
87
72
- assert_eq ! ( result. discounts . first ( ) . unwrap ( ) . targets . first ( ) . unwrap ( ) , & expected) ;
88
+ assert_eq ! ( result, expected) ;
73
89
Ok ( ( ) )
74
90
}
0 commit comments