aws-sdk-vitest-mock 0.4.0 → 0.5.0
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/README.md +177 -40
- package/index.cjs +18 -1
- package/index.d.ts +46 -1
- package/index.js +329 -222
- package/lib/matchers.d.ts +141 -0
- package/lib/mock-client.d.ts +436 -19
- package/lib/utils/paginator-helpers.d.ts +84 -0
- package/{matchers-C6AtmwWz.js → matchers-ClGOsQx8.js} +99 -0
- package/{matchers-Rq18z2C7.cjs → matchers-Dkkl4vtx.cjs} +1 -1
- package/package.json +11 -2
- package/vitest-setup.cjs +1 -1
- package/vitest-setup.js +1 -1
package/index.js
CHANGED
|
@@ -1,347 +1,454 @@
|
|
|
1
|
-
import { vi as
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { vi as v } from "vitest";
|
|
2
|
+
import { c as y } from "./matchers-ClGOsQx8.js";
|
|
3
|
+
import { m as ne } from "./matchers-ClGOsQx8.js";
|
|
4
|
+
import { readFileSync as P } from "node:fs";
|
|
5
|
+
import F from "node:path";
|
|
6
|
+
import { Readable as O } from "node:stream";
|
|
7
|
+
class f extends Error {
|
|
8
|
+
constructor(t, n, i, o) {
|
|
9
|
+
super(t), this.name = "AwsError", this.code = n, this.statusCode = i, this.retryable = o;
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
return new
|
|
14
|
-
},
|
|
15
|
-
const
|
|
16
|
-
return new
|
|
17
|
-
},
|
|
18
|
-
const
|
|
19
|
-
return new
|
|
20
|
-
},
|
|
21
|
-
const
|
|
22
|
-
return new
|
|
23
|
-
},
|
|
12
|
+
const L = (e) => {
|
|
13
|
+
const t = e ? `The specified key does not exist. Key: ${e}` : "The specified key does not exist.";
|
|
14
|
+
return new f(t, "NoSuchKey", 404, !1);
|
|
15
|
+
}, D = (e) => {
|
|
16
|
+
const t = e ? `The specified bucket does not exist. Bucket: ${e}` : "The specified bucket does not exist.";
|
|
17
|
+
return new f(t, "NoSuchBucket", 404, !1);
|
|
18
|
+
}, I = (e) => {
|
|
19
|
+
const t = e ? `Access Denied for resource: ${e}` : "Access Denied";
|
|
20
|
+
return new f(t, "AccessDenied", 403, !1);
|
|
21
|
+
}, T = (e) => {
|
|
22
|
+
const t = e ? `Requested resource not found: ${e}` : "Requested resource not found";
|
|
23
|
+
return new f(t, "ResourceNotFoundException", 400, !1);
|
|
24
|
+
}, K = () => new f(
|
|
24
25
|
"The conditional request failed",
|
|
25
26
|
"ConditionalCheckFailedException",
|
|
26
27
|
400,
|
|
27
28
|
!1
|
|
28
|
-
),
|
|
29
|
+
), M = () => new f("Rate exceeded", "Throttling", 400, !0), A = () => new f(
|
|
29
30
|
"We encountered an internal error. Please try again.",
|
|
30
31
|
"InternalServerError",
|
|
31
32
|
500,
|
|
32
33
|
!0
|
|
33
34
|
);
|
|
34
|
-
function
|
|
35
|
+
function B(e) {
|
|
36
|
+
try {
|
|
37
|
+
return JSON.stringify(e, void 0, 2);
|
|
38
|
+
} catch {
|
|
39
|
+
return typeof e == "object" && e !== null ? "[Complex Object]" : typeof e == "string" ? e : typeof e == "number" || typeof e == "boolean" ? String(e) : "[Non-serializable value]";
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function j() {
|
|
35
43
|
return {
|
|
36
44
|
enabled: !1,
|
|
37
|
-
log(
|
|
38
|
-
this.enabled
|
|
45
|
+
log(e, t) {
|
|
46
|
+
if (this.enabled)
|
|
47
|
+
if (t === void 0)
|
|
48
|
+
console.log(
|
|
49
|
+
`${y.magenta("aws-sdk-vitest-mock(debug):")} ${e}`
|
|
50
|
+
);
|
|
51
|
+
else {
|
|
52
|
+
const n = B(t);
|
|
53
|
+
console.log(
|
|
54
|
+
`${y.magenta("aws-sdk-vitest-mock(debug):")} ${e}
|
|
55
|
+
${n}`
|
|
56
|
+
);
|
|
57
|
+
}
|
|
39
58
|
}
|
|
40
59
|
};
|
|
41
60
|
}
|
|
42
|
-
function
|
|
43
|
-
|
|
61
|
+
function S(e) {
|
|
62
|
+
e.enabled = !0;
|
|
44
63
|
}
|
|
45
|
-
function w(
|
|
46
|
-
|
|
64
|
+
function w(e) {
|
|
65
|
+
e.enabled = !1;
|
|
47
66
|
}
|
|
48
|
-
function
|
|
49
|
-
const
|
|
50
|
-
return
|
|
67
|
+
function J(e) {
|
|
68
|
+
const t = F.resolve(e), n = P(t, "utf8");
|
|
69
|
+
return e.endsWith(".json") ? JSON.parse(n) : n;
|
|
51
70
|
}
|
|
52
|
-
function
|
|
53
|
-
const { pageSize:
|
|
54
|
-
if (
|
|
55
|
-
return [{ [
|
|
56
|
-
const
|
|
57
|
-
for (let r = 0; r <
|
|
58
|
-
const
|
|
59
|
-
if (
|
|
60
|
-
const a =
|
|
61
|
-
|
|
71
|
+
function _(e, t = {}) {
|
|
72
|
+
const { pageSize: n = 10, tokenKey: i = "NextToken", itemsKey: o = "Items" } = t;
|
|
73
|
+
if (e.length === 0)
|
|
74
|
+
return [{ [o]: [] }];
|
|
75
|
+
const s = [];
|
|
76
|
+
for (let r = 0; r < e.length; r += n) {
|
|
77
|
+
const c = e.slice(r, r + n), l = r + n < e.length, u = { [o]: c };
|
|
78
|
+
if (l) {
|
|
79
|
+
const g = u, a = c[c.length - 1];
|
|
80
|
+
g[i] = a;
|
|
62
81
|
}
|
|
63
|
-
|
|
82
|
+
s.push(u);
|
|
64
83
|
}
|
|
65
|
-
return
|
|
84
|
+
return s;
|
|
66
85
|
}
|
|
67
|
-
function
|
|
86
|
+
function q() {
|
|
68
87
|
return typeof process < "u" && process.versions?.node ? "node" : typeof process < "u" && process.versions?.bun ? "bun" : "browser";
|
|
69
88
|
}
|
|
70
|
-
function
|
|
71
|
-
const
|
|
72
|
-
let
|
|
73
|
-
return new
|
|
89
|
+
function z(e) {
|
|
90
|
+
const t = typeof e == "string" ? Buffer.from(e, "utf8") : Buffer.from(e);
|
|
91
|
+
let n = !1;
|
|
92
|
+
return new O({
|
|
74
93
|
read() {
|
|
75
|
-
|
|
94
|
+
n || (this.push(t), this.push(null), n = !0);
|
|
76
95
|
}
|
|
77
96
|
});
|
|
78
97
|
}
|
|
79
|
-
function
|
|
80
|
-
let
|
|
81
|
-
return typeof
|
|
82
|
-
start(
|
|
83
|
-
|
|
98
|
+
function V(e) {
|
|
99
|
+
let t;
|
|
100
|
+
return typeof e == "string" ? t = new TextEncoder().encode(e) : e instanceof Buffer ? t = new Uint8Array(e) : t = e, new ReadableStream({
|
|
101
|
+
start(n) {
|
|
102
|
+
n.enqueue(t), n.close();
|
|
84
103
|
}
|
|
85
104
|
});
|
|
86
105
|
}
|
|
87
|
-
function
|
|
88
|
-
const
|
|
89
|
-
return
|
|
106
|
+
function k(e) {
|
|
107
|
+
const t = q();
|
|
108
|
+
return t === "node" || t === "bun" ? z(e) : V(e);
|
|
90
109
|
}
|
|
91
|
-
function
|
|
92
|
-
return Object.keys(
|
|
93
|
-
const
|
|
94
|
-
return
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
) :
|
|
110
|
+
function $(e, t) {
|
|
111
|
+
return Object.keys(t).every((n) => {
|
|
112
|
+
const i = t[n], o = e[n];
|
|
113
|
+
return i && typeof i == "object" && !Array.isArray(i) ? typeof o != "object" || o === null ? !1 : $(
|
|
114
|
+
o,
|
|
115
|
+
i
|
|
116
|
+
) : o === i;
|
|
98
117
|
});
|
|
99
118
|
}
|
|
100
|
-
function
|
|
101
|
-
if (
|
|
102
|
-
if (typeof
|
|
103
|
-
return
|
|
104
|
-
const
|
|
105
|
-
return
|
|
106
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
107
|
-
const
|
|
108
|
-
return typeof
|
|
119
|
+
function N(e, t) {
|
|
120
|
+
if (e === t) return !0;
|
|
121
|
+
if (typeof e != "object" || e === null || typeof t != "object" || t === null)
|
|
122
|
+
return e === t;
|
|
123
|
+
const n = Object.keys(e), i = Object.keys(t);
|
|
124
|
+
return n.length !== i.length ? !1 : i.every((o) => {
|
|
125
|
+
if (!Object.prototype.hasOwnProperty.call(e, o)) return !1;
|
|
126
|
+
const s = e, r = t, c = s[o], l = r[o];
|
|
127
|
+
return typeof c == "object" && c !== null && typeof l == "object" && l !== null ? N(c, l) : c === l;
|
|
109
128
|
});
|
|
110
129
|
}
|
|
111
|
-
function
|
|
112
|
-
return async function(
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
`Received command: ${
|
|
116
|
-
|
|
130
|
+
function C(e) {
|
|
131
|
+
return async function(t) {
|
|
132
|
+
const n = () => this;
|
|
133
|
+
e.debugLogger.log(
|
|
134
|
+
`Received command: ${t.constructor.name}`,
|
|
135
|
+
t.input
|
|
117
136
|
);
|
|
118
|
-
const
|
|
119
|
-
|
|
137
|
+
const i = e.map.get(
|
|
138
|
+
t.constructor
|
|
120
139
|
);
|
|
121
|
-
if (
|
|
122
|
-
|
|
123
|
-
`Found ${
|
|
140
|
+
if (i) {
|
|
141
|
+
e.debugLogger.log(
|
|
142
|
+
`Found ${i.length} mock(s) for ${t.constructor.name}`
|
|
124
143
|
);
|
|
125
|
-
const
|
|
126
|
-
if (
|
|
127
|
-
|
|
128
|
-
`No matching mock found for ${
|
|
129
|
-
|
|
144
|
+
const s = i.findIndex((r) => r.strict ? r.matcher && N(t.input, r.matcher) : !r.matcher || $(t.input, r.matcher));
|
|
145
|
+
if (s === -1) {
|
|
146
|
+
e.debugLogger.log(
|
|
147
|
+
`No matching mock found for ${t.constructor.name}`,
|
|
148
|
+
t.input
|
|
149
|
+
);
|
|
150
|
+
const r = i.map((l, u) => {
|
|
151
|
+
const g = l.matcher ? JSON.stringify(l.matcher, void 0, 2) : "any input", a = l.strict ? " (strict mode)" : "";
|
|
152
|
+
return ` Mock #${u + 1}: ${g}${a}`;
|
|
153
|
+
}).join(`
|
|
154
|
+
`), c = JSON.stringify(t.input, void 0, 2);
|
|
155
|
+
throw new Error(
|
|
156
|
+
`No matching mock found for ${t.constructor.name}.
|
|
157
|
+
|
|
158
|
+
Found ${i.length} mock(s) but none matched the input.
|
|
159
|
+
|
|
160
|
+
Configured mocks:
|
|
161
|
+
${r}
|
|
162
|
+
|
|
163
|
+
Received input:
|
|
164
|
+
${c}
|
|
165
|
+
|
|
166
|
+
Tip: Enable debug mode with enableDebug() for detailed matching information.`
|
|
130
167
|
);
|
|
131
|
-
else {
|
|
132
|
-
const
|
|
133
|
-
if (!
|
|
134
|
-
throw new Error(`Mock at index ${
|
|
135
|
-
return
|
|
136
|
-
`Using mock at index ${
|
|
137
|
-
),
|
|
138
|
-
`Removed one-time mock for ${
|
|
139
|
-
)),
|
|
140
|
-
|
|
141
|
-
|
|
168
|
+
} else {
|
|
169
|
+
const r = i[s];
|
|
170
|
+
if (!r)
|
|
171
|
+
throw new Error(`Mock at index ${s} not found`);
|
|
172
|
+
return e.debugLogger.log(
|
|
173
|
+
`Using mock at index ${s} for ${t.constructor.name}`
|
|
174
|
+
), r.once && (i.splice(s, 1), e.debugLogger.log(
|
|
175
|
+
`Removed one-time mock for ${t.constructor.name}`
|
|
176
|
+
)), r.handler(
|
|
177
|
+
t.input,
|
|
178
|
+
n()
|
|
142
179
|
);
|
|
143
180
|
}
|
|
144
181
|
} else
|
|
145
|
-
|
|
146
|
-
`No mocks configured for ${
|
|
182
|
+
e.debugLogger.log(
|
|
183
|
+
`No mocks configured for ${t.constructor.name}`
|
|
147
184
|
);
|
|
185
|
+
const o = JSON.stringify(t.input, void 0, 2);
|
|
148
186
|
throw new Error(
|
|
149
|
-
`No mock configured for command: ${
|
|
187
|
+
`No mock configured for command: ${t.constructor.name}.
|
|
188
|
+
|
|
189
|
+
Received input:
|
|
190
|
+
${o}
|
|
191
|
+
|
|
192
|
+
Did you forget to call mockClient.on(${t.constructor.name})?`
|
|
150
193
|
);
|
|
151
194
|
};
|
|
152
195
|
}
|
|
153
|
-
function
|
|
154
|
-
const
|
|
155
|
-
const
|
|
156
|
-
matcher:
|
|
196
|
+
function R(e, t, n, i = {}) {
|
|
197
|
+
const o = (r, c, l) => {
|
|
198
|
+
const u = {
|
|
199
|
+
matcher: n,
|
|
157
200
|
handler: r,
|
|
158
|
-
once:
|
|
159
|
-
strict: !!
|
|
160
|
-
},
|
|
161
|
-
if (
|
|
162
|
-
const a =
|
|
163
|
-
a === -1 ?
|
|
164
|
-
|
|
165
|
-
|
|
201
|
+
once: c,
|
|
202
|
+
strict: !!i.strict
|
|
203
|
+
}, g = e.map.get(t) ?? [];
|
|
204
|
+
if (c) {
|
|
205
|
+
const a = g.findIndex((d) => !d.once);
|
|
206
|
+
a === -1 ? g.push(u) : g.splice(a, 0, u), e.map.set(
|
|
207
|
+
t,
|
|
208
|
+
g
|
|
209
|
+
), e.debugLogger.log(
|
|
210
|
+
`Configured ${l}Once for ${t.name}`,
|
|
211
|
+
n ? { matcher: n, strict: !!i.strict } : void 0
|
|
166
212
|
);
|
|
167
213
|
} else {
|
|
168
|
-
const a =
|
|
169
|
-
(
|
|
214
|
+
const a = g.filter(
|
|
215
|
+
(d) => d.once || JSON.stringify(d.matcher) !== JSON.stringify(n)
|
|
170
216
|
);
|
|
171
|
-
a.push(
|
|
172
|
-
|
|
217
|
+
a.push(u), e.map.set(
|
|
218
|
+
t,
|
|
173
219
|
a
|
|
220
|
+
), e.debugLogger.log(
|
|
221
|
+
`Configured ${l} for ${t.name}`,
|
|
222
|
+
n ? { matcher: n, strict: !!i.strict } : void 0
|
|
174
223
|
);
|
|
175
224
|
}
|
|
176
|
-
},
|
|
225
|
+
}, s = {
|
|
177
226
|
resolves(r) {
|
|
178
|
-
return
|
|
227
|
+
return o(() => Promise.resolve(r), !1, "resolves"), s;
|
|
179
228
|
},
|
|
180
229
|
rejects(r) {
|
|
181
|
-
return
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
230
|
+
return o(
|
|
231
|
+
() => {
|
|
232
|
+
const c = typeof r == "string" ? new Error(r) : r;
|
|
233
|
+
return Promise.reject(c);
|
|
234
|
+
},
|
|
235
|
+
!1,
|
|
236
|
+
"rejects"
|
|
237
|
+
), s;
|
|
185
238
|
},
|
|
186
239
|
callsFake(r) {
|
|
187
|
-
return
|
|
240
|
+
return o(r, !1, "callsFake"), s;
|
|
188
241
|
},
|
|
189
242
|
resolvesOnce(r) {
|
|
190
|
-
return
|
|
243
|
+
return o(() => Promise.resolve(r), !0, "resolves"), s;
|
|
191
244
|
},
|
|
192
245
|
rejectsOnce(r) {
|
|
193
|
-
return
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
246
|
+
return o(
|
|
247
|
+
() => {
|
|
248
|
+
const c = typeof r == "string" ? new Error(r) : r;
|
|
249
|
+
return Promise.reject(c);
|
|
250
|
+
},
|
|
251
|
+
!0,
|
|
252
|
+
"rejects"
|
|
253
|
+
), s;
|
|
197
254
|
},
|
|
198
255
|
callsFakeOnce(r) {
|
|
199
|
-
return
|
|
256
|
+
return o(r, !0, "callsFake"), s;
|
|
200
257
|
},
|
|
201
258
|
resolvesStream(r) {
|
|
202
|
-
return
|
|
203
|
-
() => Promise.resolve({ Body:
|
|
204
|
-
!1
|
|
205
|
-
|
|
259
|
+
return o(
|
|
260
|
+
() => Promise.resolve({ Body: k(r) }),
|
|
261
|
+
!1,
|
|
262
|
+
"resolvesStream"
|
|
263
|
+
), s;
|
|
206
264
|
},
|
|
207
265
|
resolvesStreamOnce(r) {
|
|
208
|
-
return
|
|
209
|
-
() => Promise.resolve({ Body:
|
|
210
|
-
!0
|
|
211
|
-
|
|
266
|
+
return o(
|
|
267
|
+
() => Promise.resolve({ Body: k(r) }),
|
|
268
|
+
!0,
|
|
269
|
+
"resolvesStream"
|
|
270
|
+
), s;
|
|
212
271
|
},
|
|
213
|
-
resolvesWithDelay(r,
|
|
214
|
-
const
|
|
215
|
-
setTimeout(() =>
|
|
272
|
+
resolvesWithDelay(r, c) {
|
|
273
|
+
const l = (u) => {
|
|
274
|
+
setTimeout(() => u(r), c);
|
|
216
275
|
};
|
|
217
|
-
return
|
|
276
|
+
return o(() => new Promise(l), !1, "resolvesWithDelay"), s;
|
|
218
277
|
},
|
|
219
|
-
rejectsWithDelay(r,
|
|
220
|
-
const
|
|
221
|
-
setTimeout(() =>
|
|
278
|
+
rejectsWithDelay(r, c) {
|
|
279
|
+
const l = typeof r == "string" ? new Error(r) : r, u = (g, a) => {
|
|
280
|
+
setTimeout(() => a(l), c);
|
|
222
281
|
};
|
|
223
|
-
return
|
|
282
|
+
return o(() => new Promise(u), !1, "rejectsWithDelay"), s;
|
|
224
283
|
},
|
|
225
284
|
rejectsWithNoSuchKey(r) {
|
|
226
|
-
return
|
|
285
|
+
return o(
|
|
286
|
+
() => Promise.reject(L(r)),
|
|
287
|
+
!1,
|
|
288
|
+
"rejectsWithNoSuchKey"
|
|
289
|
+
), s;
|
|
227
290
|
},
|
|
228
291
|
rejectsWithNoSuchBucket(r) {
|
|
229
|
-
return
|
|
292
|
+
return o(
|
|
293
|
+
() => Promise.reject(D(r)),
|
|
294
|
+
!1,
|
|
295
|
+
"rejectsWithNoSuchBucket"
|
|
296
|
+
), s;
|
|
230
297
|
},
|
|
231
298
|
rejectsWithAccessDenied(r) {
|
|
232
|
-
return
|
|
299
|
+
return o(
|
|
300
|
+
() => Promise.reject(I(r)),
|
|
301
|
+
!1,
|
|
302
|
+
"rejectsWithAccessDenied"
|
|
303
|
+
), s;
|
|
233
304
|
},
|
|
234
305
|
rejectsWithResourceNotFound(r) {
|
|
235
|
-
return
|
|
236
|
-
() => Promise.reject(
|
|
237
|
-
!1
|
|
238
|
-
|
|
306
|
+
return o(
|
|
307
|
+
() => Promise.reject(T(r)),
|
|
308
|
+
!1,
|
|
309
|
+
"rejectsWithResourceNotFound"
|
|
310
|
+
), s;
|
|
239
311
|
},
|
|
240
312
|
rejectsWithConditionalCheckFailed() {
|
|
241
|
-
return
|
|
242
|
-
() => Promise.reject(
|
|
243
|
-
!1
|
|
244
|
-
|
|
313
|
+
return o(
|
|
314
|
+
() => Promise.reject(K()),
|
|
315
|
+
!1,
|
|
316
|
+
"rejectsWithConditionalCheckFailed"
|
|
317
|
+
), s;
|
|
245
318
|
},
|
|
246
319
|
rejectsWithThrottling() {
|
|
247
|
-
return
|
|
320
|
+
return o(
|
|
321
|
+
() => Promise.reject(M()),
|
|
322
|
+
!1,
|
|
323
|
+
"rejectsWithThrottling"
|
|
324
|
+
), s;
|
|
248
325
|
},
|
|
249
326
|
rejectsWithInternalServerError() {
|
|
250
|
-
return
|
|
327
|
+
return o(
|
|
328
|
+
() => Promise.reject(A()),
|
|
329
|
+
!1,
|
|
330
|
+
"rejectsWithInternalServerError"
|
|
331
|
+
), s;
|
|
251
332
|
},
|
|
252
|
-
resolvesPaginated(r,
|
|
253
|
-
const
|
|
254
|
-
let
|
|
255
|
-
return
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
333
|
+
resolvesPaginated(r, c = {}) {
|
|
334
|
+
const l = _(r, c);
|
|
335
|
+
let u = 0;
|
|
336
|
+
return e.debugLogger.log(
|
|
337
|
+
`Configured resolvesPaginated for ${t.name}`,
|
|
338
|
+
{ pageSize: c.pageSize, itemsCount: r.length }
|
|
339
|
+
), o(
|
|
340
|
+
(g) => {
|
|
341
|
+
const a = c.tokenKey || "NextToken", d = c.inputTokenKey || a, m = g[d];
|
|
342
|
+
if (m != null) {
|
|
343
|
+
const E = c.itemsKey || "Items";
|
|
344
|
+
let b = 0;
|
|
345
|
+
for (const x of l) {
|
|
346
|
+
const p = x[E];
|
|
347
|
+
if (p && p.length > 0) {
|
|
348
|
+
const W = p[p.length - 1];
|
|
349
|
+
if (JSON.stringify(W) === JSON.stringify(m)) {
|
|
350
|
+
u = b + 1;
|
|
351
|
+
break;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
b++;
|
|
355
|
+
}
|
|
356
|
+
} else
|
|
357
|
+
u = 0;
|
|
358
|
+
const h = (
|
|
359
|
+
// eslint-disable-next-line security/detect-object-injection
|
|
360
|
+
l[u] || // eslint-disable-next-line unicorn/prefer-at -- TypeScript target doesn't support Array.at() method
|
|
361
|
+
l[l.length - 1] || l[0]
|
|
362
|
+
);
|
|
363
|
+
if (!h)
|
|
364
|
+
throw new Error("No paginated responses available");
|
|
365
|
+
return u = Math.min(u + 1, l.length - 1), Promise.resolve(h);
|
|
366
|
+
},
|
|
367
|
+
!1,
|
|
368
|
+
"resolvesPaginated"
|
|
369
|
+
), s;
|
|
276
370
|
},
|
|
277
371
|
resolvesFromFile(r) {
|
|
278
|
-
return
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
372
|
+
return e.debugLogger.log(
|
|
373
|
+
`Configured resolvesFromFile for ${t.name}`,
|
|
374
|
+
{ filePath: r }
|
|
375
|
+
), o(
|
|
376
|
+
() => {
|
|
377
|
+
const c = J(r);
|
|
378
|
+
return Promise.resolve(c);
|
|
379
|
+
},
|
|
380
|
+
!1,
|
|
381
|
+
"resolvesFromFile"
|
|
382
|
+
), s;
|
|
282
383
|
}
|
|
283
384
|
};
|
|
284
|
-
return
|
|
385
|
+
return s;
|
|
285
386
|
}
|
|
286
|
-
const
|
|
287
|
-
const
|
|
387
|
+
const ee = (e) => {
|
|
388
|
+
const t = {
|
|
288
389
|
map: /* @__PURE__ */ new WeakMap(),
|
|
289
|
-
debugLogger:
|
|
290
|
-
},
|
|
390
|
+
debugLogger: j()
|
|
391
|
+
}, n = e.prototype, i = v.spyOn(n, "send").mockImplementation(C(t));
|
|
291
392
|
return {
|
|
292
393
|
client: void 0,
|
|
293
|
-
on: (
|
|
294
|
-
|
|
295
|
-
|
|
394
|
+
on: (s, r, c) => R(
|
|
395
|
+
t,
|
|
396
|
+
s,
|
|
296
397
|
r,
|
|
297
|
-
|
|
398
|
+
c
|
|
298
399
|
),
|
|
299
400
|
reset: () => {
|
|
300
|
-
|
|
401
|
+
t.debugLogger.log("Clearing call history (mocks preserved)"), i.mockClear();
|
|
301
402
|
},
|
|
302
403
|
restore: () => {
|
|
303
|
-
|
|
404
|
+
t.debugLogger.log(
|
|
405
|
+
"Restoring original client behavior and clearing all mocks"
|
|
406
|
+
), i.mockRestore(), t.map = /* @__PURE__ */ new WeakMap();
|
|
304
407
|
},
|
|
305
|
-
calls: () =>
|
|
306
|
-
__rawCalls: () =>
|
|
408
|
+
calls: () => i.mock.calls.map((s) => s[0]),
|
|
409
|
+
__rawCalls: () => i.mock.calls,
|
|
307
410
|
enableDebug: () => {
|
|
308
|
-
|
|
411
|
+
S(t.debugLogger);
|
|
309
412
|
},
|
|
310
413
|
disableDebug: () => {
|
|
311
|
-
w(
|
|
414
|
+
w(t.debugLogger);
|
|
312
415
|
}
|
|
313
416
|
};
|
|
314
|
-
},
|
|
315
|
-
const
|
|
417
|
+
}, te = (e) => {
|
|
418
|
+
const t = {
|
|
316
419
|
map: /* @__PURE__ */ new WeakMap(),
|
|
317
|
-
debugLogger:
|
|
318
|
-
},
|
|
420
|
+
debugLogger: j()
|
|
421
|
+
}, n = v.spyOn(e, "send").mockImplementation(C(t));
|
|
319
422
|
return {
|
|
320
|
-
client:
|
|
321
|
-
on: (
|
|
322
|
-
|
|
323
|
-
n,
|
|
423
|
+
client: e,
|
|
424
|
+
on: (o, s, r) => R(
|
|
425
|
+
t,
|
|
324
426
|
o,
|
|
427
|
+
s,
|
|
325
428
|
r
|
|
326
429
|
),
|
|
327
430
|
reset: () => {
|
|
328
|
-
|
|
431
|
+
t.debugLogger.log(
|
|
432
|
+
"Clearing call history (mocks preserved) for client instance"
|
|
433
|
+
), n.mockClear();
|
|
329
434
|
},
|
|
330
435
|
restore: () => {
|
|
331
|
-
|
|
436
|
+
t.debugLogger.log(
|
|
437
|
+
"Restoring original client behavior and clearing all mocks for client instance"
|
|
438
|
+
), n.mockRestore(), t.map = /* @__PURE__ */ new WeakMap();
|
|
332
439
|
},
|
|
333
|
-
calls: () =>
|
|
334
|
-
__rawCalls: () =>
|
|
440
|
+
calls: () => n.mock.calls.map((o) => o[0]),
|
|
441
|
+
__rawCalls: () => n.mock.calls,
|
|
335
442
|
enableDebug: () => {
|
|
336
|
-
|
|
443
|
+
S(t.debugLogger);
|
|
337
444
|
},
|
|
338
445
|
disableDebug: () => {
|
|
339
|
-
w(
|
|
446
|
+
w(t.debugLogger);
|
|
340
447
|
}
|
|
341
448
|
};
|
|
342
449
|
};
|
|
343
450
|
export {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
451
|
+
ne as matchers,
|
|
452
|
+
ee as mockClient,
|
|
453
|
+
te as mockClientInstance
|
|
347
454
|
};
|