1
1
{%- if flavor contains "vanilla-js" -%}
2
- import { describe, it, expect } from "vitest";
2
+ import {describe, it, expect} from "vitest";
3
3
4
- import { generateDeliveryRun } from "./generate_delivery_run ";
4
+ import {cartDeliveryOptionsDiscountsGenerateRun } from "./cart_delivery_options_discounts_generate_run ";
5
5
import {
6
6
DeliveryDiscountSelectionStrategy,
7
7
DiscountClass,
8
8
} from "../generated/api";
9
9
10
10
/**
11
- * @typedef {import("../generated/api").CartDeliveryOptionsDiscountsGenerateRunResult} CartDeliveryOptionsDiscountsGenerateRunResult
12
- * @typedef {import("../generated/api").DeliveryInput} DeliveryInput
13
- */
11
+ * @typedef {import("../generated/api").CartDeliveryOptionsDiscountsGenerateRunResult} CartDeliveryOptionsDiscountsGenerateRunResult
12
+ * @typedef {import("../generated/api").DeliveryInput} DeliveryInput
13
+ */
14
14
15
- describe("generateDeliveryRun ", () => {
15
+ describe("cartDeliveryOptionsDiscountsGenerateRun ", () => {
16
16
const baseInput = {
17
17
cart: {
18
18
deliveryGroups: [
@@ -23,7 +23,7 @@ describe("generateDeliveryRun", () => {
23
23
},
24
24
discount: {
25
25
discountClasses: [],
26
- }
26
+ },
27
27
};
28
28
29
29
it("returns empty operations when no discount classes are present", () => {
@@ -34,7 +34,7 @@ describe("generateDeliveryRun", () => {
34
34
},
35
35
};
36
36
37
- const result = generateDeliveryRun (input);
37
+ const result = cartDeliveryOptionsDiscountsGenerateRun (input);
38
38
expect(result.operations).toHaveLength(0);
39
39
});
40
40
@@ -46,7 +46,7 @@ describe("generateDeliveryRun", () => {
46
46
},
47
47
};
48
48
49
- const result = generateDeliveryRun (input);
49
+ const result = cartDeliveryOptionsDiscountsGenerateRun (input);
50
50
expect(result.operations).toHaveLength(1);
51
51
expect(result.operations[0]).toMatchObject({
52
52
deliveryDiscountsAdd: {
@@ -82,21 +82,24 @@ describe("generateDeliveryRun", () => {
82
82
},
83
83
};
84
84
85
- expect(() => generateDeliveryRun(input)).toThrow('No delivery groups found');
85
+ expect(() => cartDeliveryOptionsDiscountsGenerateRun(input)).toThrow(
86
+ "No delivery groups found",
87
+ );
86
88
});
87
89
});
88
90
{%- elsif flavor contains "typescript" -%}
89
- import { describe, it, expect } from "vitest";
91
+ import {describe, it, expect} from "vitest";
90
92
91
- import { generateDeliveryRun } from "./generate_delivery_run ";
93
+ import {cartDeliveryOptionsDiscountsGenerateRun } from "./cart_delivery_options_discounts_generate_run ";
92
94
import {
93
95
DeliveryDiscountSelectionStrategy,
94
96
DiscountClass,
95
- CartDeliveryOptionsDiscountsGenerateRunResult
97
+ DeliveryInput,
98
+ CartDeliveryOptionsDiscountsGenerateRunResult,
96
99
} from "../generated/api";
97
100
98
- describe("generateDeliveryRun ", () => {
99
- const baseInput = {
101
+ describe("cartDeliveryOptionsDiscountsGenerateRun ", () => {
102
+ const baseInput: DeliveryInput = {
100
103
cart: {
101
104
deliveryGroups: [
102
105
{
@@ -106,30 +109,32 @@ describe("generateDeliveryRun", () => {
106
109
},
107
110
discount: {
108
111
discountClasses: [],
109
- }
112
+ },
110
113
};
111
114
112
115
it("returns empty operations when no discount classes are present", () => {
113
- const input = {
116
+ const input: DeliveryInput = {
114
117
...baseInput,
115
118
discount: {
116
119
discountClasses: [],
117
120
},
118
121
};
119
122
120
- const result: CartDeliveryOptionsDiscountsGenerateRunResult = generateDeliveryRun(input);
123
+ const result: CartDeliveryOptionsDiscountsGenerateRunResult =
124
+ cartDeliveryOptionsDiscountsGenerateRun(input);
121
125
expect(result.operations).toHaveLength(0);
122
126
});
123
127
124
128
it("returns delivery discount when shipping discount class is present", () => {
125
- const input = {
129
+ const input: DeliveryInput = {
126
130
...baseInput,
127
131
discount: {
128
132
discountClasses: [DiscountClass.Shipping],
129
133
},
130
134
};
131
135
132
- const result: CartDeliveryOptionsDiscountsGenerateRunResult = generateDeliveryRun(input);
136
+ const result: CartDeliveryOptionsDiscountsGenerateRunResult =
137
+ cartDeliveryOptionsDiscountsGenerateRun(input);
133
138
expect(result.operations).toHaveLength(1);
134
139
expect(result.operations[0]).toMatchObject({
135
140
deliveryDiscountsAdd: {
@@ -156,7 +161,7 @@ describe("generateDeliveryRun", () => {
156
161
});
157
162
158
163
it("throws error when no delivery groups are present", () => {
159
- const input = {
164
+ const input: DeliveryInput = {
160
165
cart: {
161
166
deliveryGroups: [],
162
167
},
@@ -165,7 +170,10 @@ describe("generateDeliveryRun", () => {
165
170
},
166
171
};
167
172
168
- expect(() => generateDeliveryRun(input)).toThrow('No delivery groups found');
173
+ expect(() => cartDeliveryOptionsDiscountsGenerateRun(input)).toThrow(
174
+ "No delivery groups found",
175
+ );
169
176
});
170
177
});
178
+
171
179
{%- endif -%}
0 commit comments