Skip to content

Commit 24f03d9

Browse files
committed
Add more type data
1 parent 200d1d9 commit 24f03d9

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

discounts/javascript/discount/default/src/generate_cart_run.test.liquid

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ import {
77
ProductDiscountSelectionStrategy,
88
} from "../generated/api";
99

10+
/**
11+
* @typedef {import("../generated/api").CartLinesDiscountsGenerateRunResult} CartLinesDiscountsGenerateRunResult
12+
*/
13+
1014
describe("generateCartRun", () => {
1115
it("returns a product and order discount", () => {
1216
const input = {
@@ -79,11 +83,13 @@ import { generateCartRun } from "./generate_cart_run";
7983
import {
8084
OrderDiscountSelectionStrategy,
8185
ProductDiscountSelectionStrategy,
86+
CartInput,
87+
CartLinesDiscountsGenerateRunResult
8288
} from "../generated/api";
8389

8490
describe("generateCartRun", () => {
8591
it("returns a product and order discount", () => {
86-
const input = {
92+
const input: CartInput = {
8793
cart: {
8894
lines: [
8995
{
@@ -96,7 +102,7 @@ describe("generateCartRun", () => {
96102
},
97103
};
98104

99-
const result = generateCartRun(input);
105+
const result: CartLinesDiscountsGenerateRunResult = generateCartRun(input);
100106

101107
expect(result.operations.length).toBe(2);
102108
expect(result.operations[0]).toMatchObject({

discounts/javascript/discount/default/src/generate_delivery_run.test.liquid

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,22 @@ import {
66
DeliveryDiscountSelectionStrategy,
77
} from "../generated/api";
88

9+
/**
10+
* @typedef {import("../generated/api").CartDeliveryOptionsDiscountsGenerateRunResult} CartDeliveryOptionsDiscountsGenerateRunResult
11+
* @typedef {import("../generated/api").DeliveryInput} DeliveryInput
12+
*/
13+
914
describe("generateDeliveryRun", () => {
1015
it("returns a delivery discount", () => {
11-
const input = {
16+
const input = /** @type {DeliveryInput} */ ({
1217
cart: {
1318
deliveryGroups: [
1419
{
1520
id: "gid://shopify/DeliveryGroup/0",
1621
},
1722
],
1823
},
19-
};
24+
});
2025

2126
const result = generateDeliveryRun(input);
2227

@@ -51,11 +56,13 @@ import { describe, it, expect } from "vitest";
5156
import { generateDeliveryRun } from "./generate_delivery_run";
5257
import {
5358
DeliveryDiscountSelectionStrategy,
59+
DeliveryInput,
60+
CartDeliveryOptionsDiscountsGenerateRunResult
5461
} from "../generated/api";
5562

5663
describe("generateDeliveryRun", () => {
5764
it("returns a delivery discount", () => {
58-
const input = {
65+
const input: DeliveryInput = {
5966
cart: {
6067
deliveryGroups: [
6168
{
@@ -65,7 +72,7 @@ describe("generateDeliveryRun", () => {
6572
},
6673
};
6774

68-
const result = generateDeliveryRun(input);
75+
const result: CartDeliveryOptionsDiscountsGenerateRunResult = generateDeliveryRun(input);
6976

7077
expect(result.operations.length).toBe(1);
7178
expect(result.operations[0]).toMatchObject({

0 commit comments

Comments
 (0)