11{%- if flavor contains "vanilla-js" -%}
2- import { describe, it, expect } from "vitest";
2+ import {describe, it, expect} from "vitest";
33
4- import { generateDeliveryRun } from "./generate_delivery_run ";
4+ import {cartDeliveryOptionsDiscountsGenerateRun } from "./cart_delivery_options_discounts_generate_run ";
55import {
66 DeliveryDiscountSelectionStrategy,
77 DiscountClass,
88} from "../generated/api";
99
1010/**
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+ */
1414
15- describe("generateDeliveryRun ", () => {
15+ describe("cartDeliveryOptionsDiscountsGenerateRun ", () => {
1616 const baseInput = {
1717 cart: {
1818 deliveryGroups: [
@@ -23,7 +23,7 @@ describe("generateDeliveryRun", () => {
2323 },
2424 discount: {
2525 discountClasses: [],
26- }
26+ },
2727 };
2828
2929 it("returns empty operations when no discount classes are present", () => {
@@ -34,7 +34,7 @@ describe("generateDeliveryRun", () => {
3434 },
3535 };
3636
37- const result = generateDeliveryRun (input);
37+ const result = cartDeliveryOptionsDiscountsGenerateRun (input);
3838 expect(result.operations).toHaveLength(0);
3939 });
4040
@@ -46,7 +46,7 @@ describe("generateDeliveryRun", () => {
4646 },
4747 };
4848
49- const result = generateDeliveryRun (input);
49+ const result = cartDeliveryOptionsDiscountsGenerateRun (input);
5050 expect(result.operations).toHaveLength(1);
5151 expect(result.operations[0]).toMatchObject({
5252 deliveryDiscountsAdd: {
@@ -82,21 +82,24 @@ describe("generateDeliveryRun", () => {
8282 },
8383 };
8484
85- expect(() => generateDeliveryRun(input)).toThrow('No delivery groups found');
85+ expect(() => cartDeliveryOptionsDiscountsGenerateRun(input)).toThrow(
86+ "No delivery groups found",
87+ );
8688 });
8789});
8890{%- elsif flavor contains "typescript" -%}
89- import { describe, it, expect } from "vitest";
91+ import {describe, it, expect} from "vitest";
9092
91- import { generateDeliveryRun } from "./generate_delivery_run ";
93+ import {cartDeliveryOptionsDiscountsGenerateRun } from "./cart_delivery_options_discounts_generate_run ";
9294import {
9395 DeliveryDiscountSelectionStrategy,
9496 DiscountClass,
95- CartDeliveryOptionsDiscountsGenerateRunResult
97+ DeliveryInput,
98+ CartDeliveryOptionsDiscountsGenerateRunResult,
9699} from "../generated/api";
97100
98- describe("generateDeliveryRun ", () => {
99- const baseInput = {
101+ describe("cartDeliveryOptionsDiscountsGenerateRun ", () => {
102+ const baseInput: DeliveryInput = {
100103 cart: {
101104 deliveryGroups: [
102105 {
@@ -106,30 +109,32 @@ describe("generateDeliveryRun", () => {
106109 },
107110 discount: {
108111 discountClasses: [],
109- }
112+ },
110113 };
111114
112115 it("returns empty operations when no discount classes are present", () => {
113- const input = {
116+ const input: DeliveryInput = {
114117 ...baseInput,
115118 discount: {
116119 discountClasses: [],
117120 },
118121 };
119122
120- const result: CartDeliveryOptionsDiscountsGenerateRunResult = generateDeliveryRun(input);
123+ const result: CartDeliveryOptionsDiscountsGenerateRunResult =
124+ cartDeliveryOptionsDiscountsGenerateRun(input);
121125 expect(result.operations).toHaveLength(0);
122126 });
123127
124128 it("returns delivery discount when shipping discount class is present", () => {
125- const input = {
129+ const input: DeliveryInput = {
126130 ...baseInput,
127131 discount: {
128132 discountClasses: [DiscountClass.Shipping],
129133 },
130134 };
131135
132- const result: CartDeliveryOptionsDiscountsGenerateRunResult = generateDeliveryRun(input);
136+ const result: CartDeliveryOptionsDiscountsGenerateRunResult =
137+ cartDeliveryOptionsDiscountsGenerateRun(input);
133138 expect(result.operations).toHaveLength(1);
134139 expect(result.operations[0]).toMatchObject({
135140 deliveryDiscountsAdd: {
@@ -156,7 +161,7 @@ describe("generateDeliveryRun", () => {
156161 });
157162
158163 it("throws error when no delivery groups are present", () => {
159- const input = {
164+ const input: DeliveryInput = {
160165 cart: {
161166 deliveryGroups: [],
162167 },
@@ -165,7 +170,10 @@ describe("generateDeliveryRun", () => {
165170 },
166171 };
167172
168- expect(() => generateDeliveryRun(input)).toThrow('No delivery groups found');
173+ expect(() => cartDeliveryOptionsDiscountsGenerateRun(input)).toThrow(
174+ "No delivery groups found",
175+ );
169176 });
170177});
178+
171179{%- endif -%}
0 commit comments