@htlkg/data 0.0.21 → 0.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/index.d.ts +601 -94
- package/dist/hooks/index.js +682 -73
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +691 -82
- package/dist/index.js.map +1 -1
- package/dist/mutations/index.js +4 -4
- package/dist/mutations/index.js.map +1 -1
- package/dist/queries/index.js +5 -5
- package/dist/queries/index.js.map +1 -1
- package/package.json +11 -12
- package/src/hooks/accounts/index.ts +2 -0
- package/src/hooks/{useAccounts.ts → accounts/useAccounts.ts} +48 -5
- package/src/hooks/accounts/usePaginatedAccounts.ts +166 -0
- package/src/hooks/brands/index.ts +2 -0
- package/src/hooks/{useBrands.ts → brands/useBrands.ts} +1 -1
- package/src/hooks/brands/usePaginatedBrands.ts +206 -0
- package/src/hooks/createPaginatedDataHook.ts +359 -0
- package/src/hooks/data-hook-errors.property.test.ts +4 -4
- package/src/hooks/data-hook-filters.property.test.ts +4 -4
- package/src/hooks/data-hooks.property.test.ts +4 -4
- package/src/hooks/index.ts +96 -8
- package/src/hooks/productInstances/index.ts +1 -0
- package/src/hooks/{useProductInstances.ts → productInstances/useProductInstances.ts} +9 -6
- package/src/hooks/products/index.ts +1 -0
- package/src/hooks/{useProducts.ts → products/useProducts.ts} +4 -5
- package/src/hooks/reservations/index.ts +2 -0
- package/src/hooks/reservations/usePaginatedReservations.ts +258 -0
- package/src/hooks/{useReservations.ts → reservations/useReservations.ts} +65 -10
- package/src/hooks/users/index.ts +2 -0
- package/src/hooks/users/usePaginatedUsers.ts +213 -0
- package/src/hooks/{useUsers.ts → users/useUsers.ts} +1 -1
- package/src/mutations/accounts/accounts.test.ts +287 -0
- package/src/mutations/{accounts.ts → accounts/accounts.ts} +2 -2
- package/src/mutations/accounts/index.ts +1 -0
- package/src/mutations/brands/brands.test.ts +292 -0
- package/src/mutations/{brands.ts → brands/brands.ts} +2 -2
- package/src/mutations/brands/index.ts +1 -0
- package/src/mutations/reservations/index.ts +1 -0
- package/src/mutations/{reservations.test.ts → reservations/reservations.test.ts} +1 -1
- package/src/mutations/{reservations.ts → reservations/reservations.ts} +2 -2
- package/src/mutations/users/index.ts +1 -0
- package/src/mutations/users/users.test.ts +289 -0
- package/src/mutations/{users.ts → users/users.ts} +2 -2
- package/src/queries/accounts/accounts.test.ts +228 -0
- package/src/queries/accounts/index.ts +1 -0
- package/src/queries/brands/brands.test.ts +288 -0
- package/src/queries/brands/index.ts +1 -0
- package/src/queries/products/index.ts +1 -0
- package/src/queries/products/products.test.ts +347 -0
- package/src/queries/reservations/index.ts +1 -0
- package/src/queries/users/index.ts +1 -0
- package/src/queries/users/users.test.ts +301 -0
- /package/src/queries/{accounts.ts → accounts/accounts.ts} +0 -0
- /package/src/queries/{brands.ts → brands/brands.ts} +0 -0
- /package/src/queries/{products.ts → products/products.ts} +0 -0
- /package/src/queries/{reservations.test.ts → reservations/reservations.test.ts} +0 -0
- /package/src/queries/{reservations.ts → reservations/reservations.ts} +0 -0
- /package/src/queries/{users.ts → users/users.ts} +0 -0
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Account Query Tests
|
|
3
|
+
*
|
|
4
|
+
* Tests for account query functions including filtering and relations.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { describe, it, expect, vi } from "vitest";
|
|
8
|
+
import {
|
|
9
|
+
getAccount,
|
|
10
|
+
listAccounts,
|
|
11
|
+
getAccountWithBrands,
|
|
12
|
+
} from "./accounts";
|
|
13
|
+
|
|
14
|
+
describe("Account Queries", () => {
|
|
15
|
+
const mockAccount = {
|
|
16
|
+
id: "account-001",
|
|
17
|
+
name: "Test Account",
|
|
18
|
+
logo: "logo.png",
|
|
19
|
+
subscription: { plan: "premium" },
|
|
20
|
+
settings: {},
|
|
21
|
+
status: "active",
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
describe("getAccount", () => {
|
|
25
|
+
it("should return an account by ID", async () => {
|
|
26
|
+
const mockGet = vi.fn().mockResolvedValue({
|
|
27
|
+
data: mockAccount,
|
|
28
|
+
errors: null,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const mockClient = {
|
|
32
|
+
models: {
|
|
33
|
+
Account: { get: mockGet },
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const result = await getAccount(mockClient, "account-001");
|
|
38
|
+
|
|
39
|
+
expect(result).toEqual(mockAccount);
|
|
40
|
+
expect(mockGet).toHaveBeenCalledWith({ id: "account-001" });
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("should return null when account not found", async () => {
|
|
44
|
+
const mockGet = vi.fn().mockResolvedValue({
|
|
45
|
+
data: null,
|
|
46
|
+
errors: [{ message: "Not found" }],
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const mockClient = {
|
|
50
|
+
models: {
|
|
51
|
+
Account: { get: mockGet },
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const result = await getAccount(mockClient, "nonexistent");
|
|
56
|
+
|
|
57
|
+
expect(result).toBeNull();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("should throw on unexpected error", async () => {
|
|
61
|
+
const mockGet = vi.fn().mockRejectedValue(new Error("Network error"));
|
|
62
|
+
|
|
63
|
+
const mockClient = {
|
|
64
|
+
models: {
|
|
65
|
+
Account: { get: mockGet },
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
await expect(getAccount(mockClient, "account-001")).rejects.toThrow("Network error");
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
describe("listAccounts", () => {
|
|
74
|
+
const mockAccounts = [
|
|
75
|
+
mockAccount,
|
|
76
|
+
{ ...mockAccount, id: "account-002", name: "Second Account" },
|
|
77
|
+
];
|
|
78
|
+
|
|
79
|
+
it("should return a list of accounts", async () => {
|
|
80
|
+
const mockList = vi.fn().mockResolvedValue({
|
|
81
|
+
data: mockAccounts,
|
|
82
|
+
errors: null,
|
|
83
|
+
nextToken: null,
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const mockClient = {
|
|
87
|
+
models: {
|
|
88
|
+
Account: { list: mockList },
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const result = await listAccounts(mockClient);
|
|
93
|
+
|
|
94
|
+
expect(result.items).toHaveLength(2);
|
|
95
|
+
expect(result.items[0].id).toBe("account-001");
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it("should pass filter options to the query", async () => {
|
|
99
|
+
const mockList = vi.fn().mockResolvedValue({
|
|
100
|
+
data: [mockAccount],
|
|
101
|
+
errors: null,
|
|
102
|
+
nextToken: null,
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
const mockClient = {
|
|
106
|
+
models: {
|
|
107
|
+
Account: { list: mockList },
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const filter = { status: { eq: "active" } };
|
|
112
|
+
await listAccounts(mockClient, { filter, limit: 50 });
|
|
113
|
+
|
|
114
|
+
expect(mockList).toHaveBeenCalledWith({
|
|
115
|
+
filter,
|
|
116
|
+
limit: 50,
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it("should return nextToken for pagination", async () => {
|
|
121
|
+
const mockList = vi.fn().mockResolvedValue({
|
|
122
|
+
data: [mockAccount],
|
|
123
|
+
errors: null,
|
|
124
|
+
nextToken: "token-123",
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
const mockClient = {
|
|
128
|
+
models: {
|
|
129
|
+
Account: { list: mockList },
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const result = await listAccounts(mockClient, { limit: 1 });
|
|
134
|
+
|
|
135
|
+
expect(result.nextToken).toBe("token-123");
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it("should return empty array on GraphQL error", async () => {
|
|
139
|
+
const mockList = vi.fn().mockResolvedValue({
|
|
140
|
+
data: null,
|
|
141
|
+
errors: [{ message: "Query failed" }],
|
|
142
|
+
nextToken: undefined,
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
const mockClient = {
|
|
146
|
+
models: {
|
|
147
|
+
Account: { list: mockList },
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const result = await listAccounts(mockClient);
|
|
152
|
+
|
|
153
|
+
expect(result.items).toHaveLength(0);
|
|
154
|
+
expect(result.nextToken).toBeUndefined();
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
describe("getAccountWithBrands", () => {
|
|
159
|
+
it("should return account with brands", async () => {
|
|
160
|
+
const accountWithBrands = {
|
|
161
|
+
...mockAccount,
|
|
162
|
+
brands: [
|
|
163
|
+
{ id: "brand-001", name: "Brand One" },
|
|
164
|
+
{ id: "brand-002", name: "Brand Two" },
|
|
165
|
+
],
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const mockGet = vi.fn().mockResolvedValue({
|
|
169
|
+
data: accountWithBrands,
|
|
170
|
+
errors: null,
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
const mockClient = {
|
|
174
|
+
models: {
|
|
175
|
+
Account: { get: mockGet },
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
const result = await getAccountWithBrands(mockClient, "account-001");
|
|
180
|
+
|
|
181
|
+
expect(result).toEqual(accountWithBrands);
|
|
182
|
+
expect(mockGet).toHaveBeenCalledWith(
|
|
183
|
+
{ id: "account-001" },
|
|
184
|
+
{
|
|
185
|
+
selectionSet: [
|
|
186
|
+
"id",
|
|
187
|
+
"name",
|
|
188
|
+
"logo",
|
|
189
|
+
"subscription",
|
|
190
|
+
"settings",
|
|
191
|
+
"brands.*",
|
|
192
|
+
],
|
|
193
|
+
}
|
|
194
|
+
);
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it("should return null on error", async () => {
|
|
198
|
+
const mockGet = vi.fn().mockResolvedValue({
|
|
199
|
+
data: null,
|
|
200
|
+
errors: [{ message: "Not found" }],
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
const mockClient = {
|
|
204
|
+
models: {
|
|
205
|
+
Account: { get: mockGet },
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
const result = await getAccountWithBrands(mockClient, "nonexistent");
|
|
210
|
+
|
|
211
|
+
expect(result).toBeNull();
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
it("should throw on unexpected error", async () => {
|
|
215
|
+
const mockGet = vi.fn().mockRejectedValue(new Error("Database error"));
|
|
216
|
+
|
|
217
|
+
const mockClient = {
|
|
218
|
+
models: {
|
|
219
|
+
Account: { get: mockGet },
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
await expect(getAccountWithBrands(mockClient, "account-001")).rejects.toThrow(
|
|
224
|
+
"Database error"
|
|
225
|
+
);
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./accounts";
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Brand Query Tests
|
|
3
|
+
*
|
|
4
|
+
* Tests for brand query functions including filtering and pagination.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { describe, it, expect, vi } from "vitest";
|
|
8
|
+
import {
|
|
9
|
+
getBrand,
|
|
10
|
+
listBrands,
|
|
11
|
+
getBrandWithProducts,
|
|
12
|
+
listBrandsByAccount,
|
|
13
|
+
listActiveBrands,
|
|
14
|
+
} from "./brands";
|
|
15
|
+
|
|
16
|
+
describe("Brand Queries", () => {
|
|
17
|
+
const mockBrand = {
|
|
18
|
+
id: "brand-001",
|
|
19
|
+
name: "Test Brand",
|
|
20
|
+
accountId: "account-123",
|
|
21
|
+
logo: "logo.png",
|
|
22
|
+
timezone: "America/New_York",
|
|
23
|
+
status: "active",
|
|
24
|
+
settings: {},
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
describe("getBrand", () => {
|
|
28
|
+
it("should return a brand by ID", async () => {
|
|
29
|
+
const mockGet = vi.fn().mockResolvedValue({
|
|
30
|
+
data: mockBrand,
|
|
31
|
+
errors: null,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const mockClient = {
|
|
35
|
+
models: {
|
|
36
|
+
Brand: { get: mockGet },
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const result = await getBrand(mockClient, "brand-001");
|
|
41
|
+
|
|
42
|
+
expect(result).toEqual(mockBrand);
|
|
43
|
+
expect(mockGet).toHaveBeenCalledWith({ id: "brand-001" });
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("should return null when brand not found", async () => {
|
|
47
|
+
const mockGet = vi.fn().mockResolvedValue({
|
|
48
|
+
data: null,
|
|
49
|
+
errors: [{ message: "Not found" }],
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const mockClient = {
|
|
53
|
+
models: {
|
|
54
|
+
Brand: { get: mockGet },
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const result = await getBrand(mockClient, "nonexistent");
|
|
59
|
+
|
|
60
|
+
expect(result).toBeNull();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("should throw on unexpected error", async () => {
|
|
64
|
+
const mockGet = vi.fn().mockRejectedValue(new Error("Network error"));
|
|
65
|
+
|
|
66
|
+
const mockClient = {
|
|
67
|
+
models: {
|
|
68
|
+
Brand: { get: mockGet },
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
await expect(getBrand(mockClient, "brand-001")).rejects.toThrow("Network error");
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
describe("listBrands", () => {
|
|
77
|
+
const mockBrands = [
|
|
78
|
+
mockBrand,
|
|
79
|
+
{ ...mockBrand, id: "brand-002", name: "Second Brand" },
|
|
80
|
+
];
|
|
81
|
+
|
|
82
|
+
it("should return a list of brands", async () => {
|
|
83
|
+
const mockList = vi.fn().mockResolvedValue({
|
|
84
|
+
data: mockBrands,
|
|
85
|
+
errors: null,
|
|
86
|
+
nextToken: null,
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const mockClient = {
|
|
90
|
+
models: {
|
|
91
|
+
Brand: { list: mockList },
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const result = await listBrands(mockClient);
|
|
96
|
+
|
|
97
|
+
expect(result.items).toHaveLength(2);
|
|
98
|
+
expect(result.items[0].id).toBe("brand-001");
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it("should pass filter options to the query", async () => {
|
|
102
|
+
const mockList = vi.fn().mockResolvedValue({
|
|
103
|
+
data: [mockBrand],
|
|
104
|
+
errors: null,
|
|
105
|
+
nextToken: null,
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const mockClient = {
|
|
109
|
+
models: {
|
|
110
|
+
Brand: { list: mockList },
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const filter = { status: { eq: "active" } };
|
|
115
|
+
await listBrands(mockClient, { filter, limit: 50 });
|
|
116
|
+
|
|
117
|
+
expect(mockList).toHaveBeenCalledWith({
|
|
118
|
+
filter,
|
|
119
|
+
limit: 50,
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it("should return nextToken for pagination", async () => {
|
|
124
|
+
const mockList = vi.fn().mockResolvedValue({
|
|
125
|
+
data: [mockBrand],
|
|
126
|
+
errors: null,
|
|
127
|
+
nextToken: "token-123",
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
const mockClient = {
|
|
131
|
+
models: {
|
|
132
|
+
Brand: { list: mockList },
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const result = await listBrands(mockClient, { limit: 1 });
|
|
137
|
+
|
|
138
|
+
expect(result.nextToken).toBe("token-123");
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it("should return empty array on GraphQL error", async () => {
|
|
142
|
+
const mockList = vi.fn().mockResolvedValue({
|
|
143
|
+
data: null,
|
|
144
|
+
errors: [{ message: "Query failed" }],
|
|
145
|
+
nextToken: undefined,
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
const mockClient = {
|
|
149
|
+
models: {
|
|
150
|
+
Brand: { list: mockList },
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const result = await listBrands(mockClient);
|
|
155
|
+
|
|
156
|
+
expect(result.items).toHaveLength(0);
|
|
157
|
+
expect(result.nextToken).toBeUndefined();
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
describe("getBrandWithProducts", () => {
|
|
162
|
+
it("should return brand with product instances", async () => {
|
|
163
|
+
const brandWithProducts = {
|
|
164
|
+
...mockBrand,
|
|
165
|
+
productInstances: [
|
|
166
|
+
{ id: "pi-001", productId: "prod-001", enabled: true },
|
|
167
|
+
],
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const mockGet = vi.fn().mockResolvedValue({
|
|
171
|
+
data: brandWithProducts,
|
|
172
|
+
errors: null,
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
const mockClient = {
|
|
176
|
+
models: {
|
|
177
|
+
Brand: { get: mockGet },
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const result = await getBrandWithProducts(mockClient, "brand-001");
|
|
182
|
+
|
|
183
|
+
expect(result).toEqual(brandWithProducts);
|
|
184
|
+
expect(mockGet).toHaveBeenCalledWith(
|
|
185
|
+
{ id: "brand-001" },
|
|
186
|
+
{
|
|
187
|
+
selectionSet: [
|
|
188
|
+
"id",
|
|
189
|
+
"name",
|
|
190
|
+
"accountId",
|
|
191
|
+
"logo",
|
|
192
|
+
"timezone",
|
|
193
|
+
"status",
|
|
194
|
+
"settings",
|
|
195
|
+
"productInstances.*",
|
|
196
|
+
],
|
|
197
|
+
}
|
|
198
|
+
);
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
it("should return null on error", async () => {
|
|
202
|
+
const mockGet = vi.fn().mockResolvedValue({
|
|
203
|
+
data: null,
|
|
204
|
+
errors: [{ message: "Not found" }],
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
const mockClient = {
|
|
208
|
+
models: {
|
|
209
|
+
Brand: { get: mockGet },
|
|
210
|
+
},
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
const result = await getBrandWithProducts(mockClient, "nonexistent");
|
|
214
|
+
|
|
215
|
+
expect(result).toBeNull();
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
describe("listBrandsByAccount", () => {
|
|
220
|
+
it("should filter brands by account ID", async () => {
|
|
221
|
+
const mockList = vi.fn().mockResolvedValue({
|
|
222
|
+
data: [mockBrand],
|
|
223
|
+
errors: null,
|
|
224
|
+
nextToken: null,
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
const mockClient = {
|
|
228
|
+
models: {
|
|
229
|
+
Brand: { list: mockList },
|
|
230
|
+
},
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
await listBrandsByAccount(mockClient, "account-123");
|
|
234
|
+
|
|
235
|
+
expect(mockList).toHaveBeenCalledWith({
|
|
236
|
+
filter: { accountId: { eq: "account-123" } },
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it("should support pagination options", async () => {
|
|
241
|
+
const mockList = vi.fn().mockResolvedValue({
|
|
242
|
+
data: [mockBrand],
|
|
243
|
+
errors: null,
|
|
244
|
+
nextToken: "next-page",
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
const mockClient = {
|
|
248
|
+
models: {
|
|
249
|
+
Brand: { list: mockList },
|
|
250
|
+
},
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
const result = await listBrandsByAccount(mockClient, "account-123", {
|
|
254
|
+
limit: 10,
|
|
255
|
+
nextToken: "current-token",
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
expect(mockList).toHaveBeenCalledWith({
|
|
259
|
+
filter: { accountId: { eq: "account-123" } },
|
|
260
|
+
limit: 10,
|
|
261
|
+
nextToken: "current-token",
|
|
262
|
+
});
|
|
263
|
+
expect(result.nextToken).toBe("next-page");
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
describe("listActiveBrands", () => {
|
|
268
|
+
it("should filter brands by active status", async () => {
|
|
269
|
+
const mockList = vi.fn().mockResolvedValue({
|
|
270
|
+
data: [mockBrand],
|
|
271
|
+
errors: null,
|
|
272
|
+
nextToken: null,
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
const mockClient = {
|
|
276
|
+
models: {
|
|
277
|
+
Brand: { list: mockList },
|
|
278
|
+
},
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
await listActiveBrands(mockClient);
|
|
282
|
+
|
|
283
|
+
expect(mockList).toHaveBeenCalledWith({
|
|
284
|
+
filter: { status: { eq: "active" } },
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./brands";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./products";
|