@granito/vitest-marbles 1.0.0-dev.2 → 1.0.0-dev.4
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/index.d.ts +3 -0
- package/index.d.ts.map +1 -0
- package/index.js +276 -0
- package/lib/assert-deep-equal.d.ts +5 -0
- package/lib/assert-deep-equal.d.ts.map +1 -0
- package/lib/internal-matchers.d.ts +14 -0
- package/lib/internal-matchers.d.ts.map +1 -0
- package/{dist/src → lib}/marbles-glossary.d.ts +1 -0
- package/lib/marbles-glossary.d.ts.map +1 -0
- package/lib/marbles.d.ts +7 -0
- package/lib/marbles.d.ts.map +1 -0
- package/{dist/src → lib}/marblizer.d.ts +2 -1
- package/lib/marblizer.d.ts.map +1 -0
- package/lib/matchers.d.ts +14 -0
- package/lib/matchers.d.ts.map +1 -0
- package/{dist/src → lib}/notification-event.d.ts +1 -0
- package/lib/notification-event.d.ts.map +1 -0
- package/{dist/src → lib}/notification-kind.d.ts +1 -0
- package/lib/notification-kind.d.ts.map +1 -0
- package/{dist/src/rxjs → lib}/scheduler.d.ts +1 -3
- package/lib/scheduler.d.ts.map +1 -0
- package/{dist/src/rxjs → lib}/strip-alignment-chars.d.ts +1 -0
- package/lib/strip-alignment-chars.d.ts.map +1 -0
- package/{dist/src/rxjs → lib}/types.d.ts +4 -0
- package/lib/types.d.ts.map +1 -0
- package/package.json +46 -21
- package/dist/index.d.ts +0 -20
- package/dist/index.js +0 -60
- package/dist/index.js.map +0 -1
- package/dist/src/marbles-glossary.js +0 -11
- package/dist/src/marbles-glossary.js.map +0 -1
- package/dist/src/marblizer.js +0 -47
- package/dist/src/marblizer.js.map +0 -1
- package/dist/src/notification-event.js +0 -11
- package/dist/src/notification-event.js.map +0 -1
- package/dist/src/notification-kind.js +0 -8
- package/dist/src/notification-kind.js.map +0 -1
- package/dist/src/rxjs/assert-deep-equal.d.ts +0 -4
- package/dist/src/rxjs/assert-deep-equal.js +0 -19
- package/dist/src/rxjs/assert-deep-equal.js.map +0 -1
- package/dist/src/rxjs/cold-observable.d.ts +0 -11
- package/dist/src/rxjs/cold-observable.js +0 -19
- package/dist/src/rxjs/cold-observable.js.map +0 -1
- package/dist/src/rxjs/hot-observable.d.ts +0 -11
- package/dist/src/rxjs/hot-observable.js +0 -19
- package/dist/src/rxjs/hot-observable.js.map +0 -1
- package/dist/src/rxjs/scheduler.js +0 -22
- package/dist/src/rxjs/scheduler.js.map +0 -1
- package/dist/src/rxjs/strip-alignment-chars.js +0 -4
- package/dist/src/rxjs/strip-alignment-chars.js.map +0 -1
- package/dist/src/rxjs/types.js +0 -2
- package/dist/src/rxjs/types.js.map +0 -1
- package/dist/src/vitest/custom-matchers.d.ts +0 -13
- package/dist/src/vitest/custom-matchers.js +0 -103
- package/dist/src/vitest/custom-matchers.js.map +0 -1
package/index.d.ts
ADDED
package/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC"}
|
package/index.js
ADDED
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
// src/lib/scheduler.ts
|
|
2
|
+
import { TestScheduler } from "rxjs/testing";
|
|
3
|
+
|
|
4
|
+
// src/lib/notification-event.ts
|
|
5
|
+
var NotificationEvent = class {
|
|
6
|
+
constructor(start) {
|
|
7
|
+
this.start = start;
|
|
8
|
+
}
|
|
9
|
+
marbles = "";
|
|
10
|
+
get end() {
|
|
11
|
+
return this.start + this.marbles.length;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// src/lib/notification-kind.ts
|
|
16
|
+
var ValueLiteral = {};
|
|
17
|
+
var NotificationKindChars = {
|
|
18
|
+
N: ValueLiteral,
|
|
19
|
+
C: "|" /* Completion */,
|
|
20
|
+
E: "#" /* Error */
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// src/lib/marblizer.ts
|
|
24
|
+
var frameStep = 10;
|
|
25
|
+
var Marblizer = class _Marblizer {
|
|
26
|
+
static marblize(messages) {
|
|
27
|
+
const emissions = _Marblizer.getNotificationEvents(messages);
|
|
28
|
+
let marbles = "";
|
|
29
|
+
for (let i = 0, prevEndFrame = 0; i < emissions.length; prevEndFrame = emissions[i].end, i++)
|
|
30
|
+
marbles = `${marbles}${"-" /* TimeFrame */.repeat(emissions[i].start - prevEndFrame) + emissions[i].marbles}`;
|
|
31
|
+
return marbles;
|
|
32
|
+
}
|
|
33
|
+
static marblizeSubscriptions(logs) {
|
|
34
|
+
return logs.map(
|
|
35
|
+
(log) => this.marblizeLogEntry(log.subscribedFrame / frameStep, "^" /* Subscription */) + this.marblizeLogEntry(
|
|
36
|
+
(log.unsubscribedFrame - log.subscribedFrame) / frameStep - 1,
|
|
37
|
+
"!" /* Unsubscription */
|
|
38
|
+
)
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
static marblizeLogEntry(logPoint, symbol) {
|
|
42
|
+
return logPoint !== Infinity ? "-" /* TimeFrame */.repeat(logPoint) + symbol : "";
|
|
43
|
+
}
|
|
44
|
+
static getNotificationEvents(messages) {
|
|
45
|
+
const framesToEmissions = messages.reduce((result, message) => {
|
|
46
|
+
if (!result[message.frame])
|
|
47
|
+
result[message.frame] = new NotificationEvent(message.frame / frameStep);
|
|
48
|
+
const event = result[message.frame];
|
|
49
|
+
event.marbles += _Marblizer.extractMarble(message);
|
|
50
|
+
return result;
|
|
51
|
+
}, {});
|
|
52
|
+
const events = Object.keys(framesToEmissions).map((frame) => framesToEmissions[Number(frame)]);
|
|
53
|
+
_Marblizer.encloseGroupEvents(events);
|
|
54
|
+
return events;
|
|
55
|
+
}
|
|
56
|
+
static extractMarble(message) {
|
|
57
|
+
let marble = NotificationKindChars[message.notification.kind];
|
|
58
|
+
if (marble === ValueLiteral)
|
|
59
|
+
marble = message.notification.value;
|
|
60
|
+
return marble;
|
|
61
|
+
}
|
|
62
|
+
static encloseGroupEvents(events) {
|
|
63
|
+
events.forEach((event) => {
|
|
64
|
+
if (event.marbles.length > 1)
|
|
65
|
+
event.marbles = `${"(" /* GroupStart */}${event.marbles}${")" /* GroupEnd */}`;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// src/lib/internal-matchers.ts
|
|
71
|
+
var internalMatchers = {
|
|
72
|
+
toBeNotifications(actual, expected) {
|
|
73
|
+
let actualMarble = actual;
|
|
74
|
+
let expectedMarble = expected;
|
|
75
|
+
if (canMarblize(actual, expected)) {
|
|
76
|
+
actualMarble = Marblizer.marblize(actual);
|
|
77
|
+
expectedMarble = Marblizer.marblize(expected);
|
|
78
|
+
}
|
|
79
|
+
const pass = this.equals(actualMarble, expectedMarble);
|
|
80
|
+
const message = pass ? () => this.utils.matcherHint(".not.toBeNotifications") + `
|
|
81
|
+
|
|
82
|
+
Expected notifications to not be:
|
|
83
|
+
${this.utils.printExpected(expectedMarble)}
|
|
84
|
+
But got:
|
|
85
|
+
${this.utils.printReceived(actualMarble)}` : () => {
|
|
86
|
+
const diffString = this.utils.diff(expectedMarble, actualMarble, {
|
|
87
|
+
expand: true
|
|
88
|
+
});
|
|
89
|
+
return this.utils.matcherHint(".toBeNotifications") + `
|
|
90
|
+
|
|
91
|
+
Expected notifications to be:
|
|
92
|
+
${this.utils.printExpected(expectedMarble)}
|
|
93
|
+
But got:
|
|
94
|
+
${this.utils.printReceived(actualMarble)}` + (diffString ? `
|
|
95
|
+
|
|
96
|
+
Difference:
|
|
97
|
+
|
|
98
|
+
${diffString}` : "");
|
|
99
|
+
};
|
|
100
|
+
return {
|
|
101
|
+
pass,
|
|
102
|
+
message
|
|
103
|
+
};
|
|
104
|
+
},
|
|
105
|
+
toBeSubscriptions(actual, expected) {
|
|
106
|
+
const actualMarbleArray = Marblizer.marblizeSubscriptions(actual);
|
|
107
|
+
const expectedMarbleArray = Marblizer.marblizeSubscriptions(expected);
|
|
108
|
+
const pass = subscriptionsPass(actualMarbleArray, expectedMarbleArray);
|
|
109
|
+
const message = pass ? () => this.utils.matcherHint(".not.toHaveSubscriptions") + `
|
|
110
|
+
|
|
111
|
+
Expected observable to not have the following subscription points:
|
|
112
|
+
${this.utils.printExpected(expectedMarbleArray)}
|
|
113
|
+
But got:
|
|
114
|
+
${this.utils.printReceived(actualMarbleArray)}` : () => {
|
|
115
|
+
const diffString = this.utils.diff(expectedMarbleArray, actualMarbleArray, {
|
|
116
|
+
expand: true
|
|
117
|
+
});
|
|
118
|
+
return this.utils.matcherHint(".toHaveSubscriptions") + `
|
|
119
|
+
|
|
120
|
+
Expected observable to have the following subscription points:
|
|
121
|
+
${this.utils.printExpected(expectedMarbleArray)}
|
|
122
|
+
But got:
|
|
123
|
+
${this.utils.printReceived(actualMarbleArray)}` + (diffString ? `
|
|
124
|
+
|
|
125
|
+
Difference:
|
|
126
|
+
|
|
127
|
+
${diffString}` : "");
|
|
128
|
+
};
|
|
129
|
+
return {
|
|
130
|
+
pass,
|
|
131
|
+
message
|
|
132
|
+
};
|
|
133
|
+
},
|
|
134
|
+
toHaveEmptySubscriptions(actual) {
|
|
135
|
+
const pass = !(actual && actual.length > 0);
|
|
136
|
+
let marbles;
|
|
137
|
+
if (actual && actual.length > 0)
|
|
138
|
+
marbles = Marblizer.marblizeSubscriptions(actual);
|
|
139
|
+
const message = pass ? () => this.utils.matcherHint(".not.toHaveNoSubscriptions") + `
|
|
140
|
+
|
|
141
|
+
Expected observable to have at least one subscription point, but got nothing` + this.utils.printReceived("") : () => this.utils.matcherHint(".toHaveNoSubscriptions") + `
|
|
142
|
+
|
|
143
|
+
Expected observable to have no subscription points
|
|
144
|
+
But got:
|
|
145
|
+
${this.utils.printReceived(marbles)}
|
|
146
|
+
|
|
147
|
+
`;
|
|
148
|
+
return {
|
|
149
|
+
pass,
|
|
150
|
+
message
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
expect.extend(internalMatchers);
|
|
155
|
+
function canMarblize(...messages) {
|
|
156
|
+
return messages.every(isMessagesMarblizable);
|
|
157
|
+
}
|
|
158
|
+
function isMessagesMarblizable(messages) {
|
|
159
|
+
return messages.every(
|
|
160
|
+
({ notification }) => notification.kind === "C" || notification.kind === "E" && notification.error === "error" || notification.kind === "N" && isCharacter(notification.value)
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
function isCharacter(value) {
|
|
164
|
+
return typeof value === "string" && value.length === 1 || value !== void 0 && JSON.stringify(value).length === 1;
|
|
165
|
+
}
|
|
166
|
+
function subscriptionsPass(actualMarbleArray, expectedMarbleArray) {
|
|
167
|
+
if (actualMarbleArray.length !== expectedMarbleArray.length)
|
|
168
|
+
return false;
|
|
169
|
+
for (const actualMarble of actualMarbleArray)
|
|
170
|
+
if (!expectedMarbleArray.includes(actualMarble))
|
|
171
|
+
return false;
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// src/lib/assert-deep-equal.ts
|
|
176
|
+
function expectedIsSubscriptionLogArray(actual, expected) {
|
|
177
|
+
return actual.length === 0 && expected.length === 0 || expected.length !== 0 && expected[0].subscribedFrame !== void 0;
|
|
178
|
+
}
|
|
179
|
+
function actualIsSubscriptionsAndExpectedIsEmpty(actual, expected) {
|
|
180
|
+
return expected.length === 0 && actual.length !== 0 && actual[0].subscribedFrame !== void 0;
|
|
181
|
+
}
|
|
182
|
+
function assertDeepEqual(actual, expected) {
|
|
183
|
+
if (!expected)
|
|
184
|
+
return;
|
|
185
|
+
if (actualIsSubscriptionsAndExpectedIsEmpty(actual, expected))
|
|
186
|
+
expect(actual).toHaveEmptySubscriptions();
|
|
187
|
+
else if (expectedIsSubscriptionLogArray(actual, expected))
|
|
188
|
+
expect(actual).toBeSubscriptions(expected);
|
|
189
|
+
else
|
|
190
|
+
expect(actual).toBeNotifications(expected);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// src/lib/scheduler.ts
|
|
194
|
+
var Scheduler = class _Scheduler {
|
|
195
|
+
static instance;
|
|
196
|
+
static init() {
|
|
197
|
+
_Scheduler.instance = new TestScheduler(assertDeepEqual);
|
|
198
|
+
}
|
|
199
|
+
static get() {
|
|
200
|
+
if (!_Scheduler.instance)
|
|
201
|
+
throw new Error("Scheduler is not initialized");
|
|
202
|
+
return _Scheduler.instance;
|
|
203
|
+
}
|
|
204
|
+
static reset() {
|
|
205
|
+
_Scheduler.instance = null;
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
// src/lib/strip-alignment-chars.ts
|
|
210
|
+
function stripAlignmentChars(marbles) {
|
|
211
|
+
return marbles.replace(/^ +/, "");
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// src/lib/marbles.ts
|
|
215
|
+
function cold(marbles, values, error) {
|
|
216
|
+
return Scheduler.get().createColdObservable(stripAlignmentChars(marbles), values, error);
|
|
217
|
+
}
|
|
218
|
+
function hot(marbles, values, error) {
|
|
219
|
+
return Scheduler.get().createHotObservable(stripAlignmentChars(marbles), values, error);
|
|
220
|
+
}
|
|
221
|
+
function time(marbles) {
|
|
222
|
+
return Scheduler.get().createTime(stripAlignmentChars(marbles));
|
|
223
|
+
}
|
|
224
|
+
function schedule(work, delay) {
|
|
225
|
+
return Scheduler.get().schedule(work, delay);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// src/lib/matchers.ts
|
|
229
|
+
import { TestScheduler as TestScheduler2 } from "rxjs/testing";
|
|
230
|
+
var dummyResult = {
|
|
231
|
+
pass: true,
|
|
232
|
+
message: () => ""
|
|
233
|
+
};
|
|
234
|
+
expect.extend({
|
|
235
|
+
toHaveSubscriptions(actual, marbles) {
|
|
236
|
+
const sanitizedMarbles = Array.isArray(marbles) ? marbles.map(stripAlignmentChars) : stripAlignmentChars(marbles);
|
|
237
|
+
Scheduler.get().expectSubscriptions(actual.subscriptions).toBe(sanitizedMarbles);
|
|
238
|
+
return dummyResult;
|
|
239
|
+
},
|
|
240
|
+
toHaveNoSubscriptions(actual) {
|
|
241
|
+
Scheduler.get().expectSubscriptions(actual.subscriptions).toBe([]);
|
|
242
|
+
return dummyResult;
|
|
243
|
+
},
|
|
244
|
+
toBeObservable(actual, expected) {
|
|
245
|
+
Scheduler.get().expectObservable(actual).toEqual(expected);
|
|
246
|
+
return dummyResult;
|
|
247
|
+
},
|
|
248
|
+
toBeMarble(actual, marbles) {
|
|
249
|
+
Scheduler.get().expectObservable(actual).toBe(stripAlignmentChars(marbles));
|
|
250
|
+
return dummyResult;
|
|
251
|
+
},
|
|
252
|
+
toSatisfyOnFlush(actual, func) {
|
|
253
|
+
Scheduler.get().expectObservable(actual);
|
|
254
|
+
const flushTests = Scheduler.get()["flushTests"];
|
|
255
|
+
flushTests[flushTests.length - 1].ready = true;
|
|
256
|
+
onFlush.push(func);
|
|
257
|
+
return dummyResult;
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
var onFlush = [];
|
|
261
|
+
beforeEach(() => {
|
|
262
|
+
Scheduler.init();
|
|
263
|
+
onFlush = [];
|
|
264
|
+
});
|
|
265
|
+
afterEach(() => {
|
|
266
|
+
Scheduler.get().run(() => TestScheduler2.frameTimeFactor = 10);
|
|
267
|
+
while (onFlush.length > 0)
|
|
268
|
+
onFlush.shift()?.();
|
|
269
|
+
Scheduler.reset();
|
|
270
|
+
});
|
|
271
|
+
export {
|
|
272
|
+
cold,
|
|
273
|
+
hot,
|
|
274
|
+
schedule,
|
|
275
|
+
time
|
|
276
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { SubscriptionLog, TestMessages } from './types';
|
|
2
|
+
import './internal-matchers';
|
|
3
|
+
export type MessagesOrSubscriptions = TestMessages | SubscriptionLog[];
|
|
4
|
+
export declare function assertDeepEqual(actual: MessagesOrSubscriptions, expected: MessagesOrSubscriptions): void;
|
|
5
|
+
//# sourceMappingURL=assert-deep-equal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assert-deep-equal.d.ts","sourceRoot":"","sources":["../../../src/lib/assert-deep-equal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,qBAAqB,CAAC;AAE7B,MAAM,MAAM,uBAAuB,GAAG,YAAY,GAAG,eAAe,EAAE,CAAC;AAavE,wBAAgB,eAAe,CAAC,MAAM,EAAE,uBAAuB,EAAE,QAAQ,EAAE,uBAAuB,GAAG,IAAI,CAUxG"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SubscriptionLog, TestMessages } from './types';
|
|
2
|
+
import { MatchersObject } from '@vitest/expect';
|
|
3
|
+
interface InternalMatchers<R = unknown> {
|
|
4
|
+
toBeNotifications: (messages: TestMessages) => R;
|
|
5
|
+
toBeSubscriptions: (subscriptions: SubscriptionLog[]) => R;
|
|
6
|
+
toHaveEmptySubscriptions: () => R;
|
|
7
|
+
}
|
|
8
|
+
export declare const internalMatchers: MatchersObject;
|
|
9
|
+
declare module 'vitest' {
|
|
10
|
+
interface Matchers<T = any> extends InternalMatchers<T> {
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=internal-matchers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-matchers.d.ts","sourceRoot":"","sources":["../../../src/lib/internal-matchers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAExD,OAAO,EAAqB,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEnE,UAAU,gBAAgB,CAAC,CAAC,GAAG,OAAO;IACpC,iBAAiB,EAAE,CAAC,QAAQ,EAAE,YAAY,KAAK,CAAC,CAAC;IAEjD,iBAAiB,EAAE,CAAC,aAAa,EAAE,eAAe,EAAE,KAAK,CAAC,CAAC;IAE3D,wBAAwB,EAAE,MAAM,CAAC,CAAC;CACnC;AAED,eAAO,MAAM,gBAAgB,EAAE,cA4F9B,CAAA;AAID,OAAO,QAAQ,QAAQ,CAAC;IACtB,UAAU,QAAQ,CAAC,CAAC,GAAG,GAAG,CAAE,SAAQ,gBAAgB,CAAC,CAAC,CAAC;KACtD;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marbles-glossary.d.ts","sourceRoot":"","sources":["../../../src/lib/marbles-glossary.ts"],"names":[],"mappings":"AAAA,oBAAY,eAAe;IACzB,UAAU,MAAM;IAChB,KAAK,MAAM;IACX,SAAS,MAAM;IACf,YAAY,MAAM;IAClB,cAAc,MAAM;IACpB,UAAU,MAAM;IAChB,QAAQ,MAAM;CACf"}
|
package/lib/marbles.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Subscription } from 'rxjs';
|
|
2
|
+
import { ColdObservable, HotObservable } from './types';
|
|
3
|
+
export declare function cold<T = string>(marbles: string, values?: Record<string, T>, error?: any): ColdObservable<T>;
|
|
4
|
+
export declare function hot<T = string>(marbles: string, values?: Record<string, T>, error?: any): HotObservable<T>;
|
|
5
|
+
export declare function time(marbles: string): number;
|
|
6
|
+
export declare function schedule(work: () => void, delay: number): Subscription;
|
|
7
|
+
//# sourceMappingURL=marbles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marbles.d.ts","sourceRoot":"","sources":["../../../src/lib/marbles.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExD,wBAAgB,IAAI,CAAC,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,cAAc,CAAC,CAAC,CAAC,CAE5G;AAED,wBAAgB,GAAG,CAAC,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,aAAa,CAAC,CAAC,CAAC,CAE1G;AAED,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,YAAY,CAEtE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SubscriptionLog, TestMessages } from './
|
|
1
|
+
import { SubscriptionLog, TestMessages } from './types';
|
|
2
2
|
export declare class Marblizer {
|
|
3
3
|
static marblize(messages: TestMessages): string;
|
|
4
4
|
static marblizeSubscriptions(logs: SubscriptionLog[]): string[];
|
|
@@ -7,3 +7,4 @@ export declare class Marblizer {
|
|
|
7
7
|
private static extractMarble;
|
|
8
8
|
private static encloseGroupEvents;
|
|
9
9
|
}
|
|
10
|
+
//# sourceMappingURL=marblizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marblizer.d.ts","sourceRoot":"","sources":["../../../src/lib/marblizer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAOxD,qBAAa,SAAS;WACN,QAAQ,CAAC,QAAQ,EAAE,YAAY,GAAG,MAAM;WAYxC,qBAAqB,CAAC,IAAI,EAAE,eAAe,EAAE,GAAG,MAAM,EAAE;IAQtE,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAI/B,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAqBpC,OAAO,CAAC,MAAM,CAAC,aAAa;IAS5B,OAAO,CAAC,MAAM,CAAC,kBAAkB;CAMlC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
interface CustomMatchers<R = unknown> {
|
|
3
|
+
toBeObservable<T>(observable: Observable<T>): R;
|
|
4
|
+
toHaveSubscriptions(marbles: string | string[]): R;
|
|
5
|
+
toHaveNoSubscriptions(): R;
|
|
6
|
+
toBeMarble(marble: string): R;
|
|
7
|
+
toSatisfyOnFlush(func: () => void): R;
|
|
8
|
+
}
|
|
9
|
+
declare module 'vitest' {
|
|
10
|
+
interface Matchers<T = any> extends CustomMatchers<T> {
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=matchers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matchers.d.ts","sourceRoot":"","sources":["../../../src/lib/matchers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAIlC,UAAU,cAAc,CAAC,CAAC,GAAG,OAAO;IAClC,cAAc,CAAC,CAAC,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAEhD,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC;IAEnD,qBAAqB,IAAI,CAAC,CAAC;IAE3B,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC;IAE9B,gBAAgB,CAAC,IAAI,EAAE,MAAM,IAAI,GAAG,CAAC,CAAC;CACvC;AAED,OAAO,QAAQ,QAAQ,CAAC;IACtB,UAAU,QAAQ,CAAC,CAAC,GAAG,GAAG,CAAE,SAAQ,cAAc,CAAC,CAAC,CAAC;KACpD;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification-event.d.ts","sourceRoot":"","sources":["../../../src/lib/notification-event.ts"],"names":[],"mappings":"AAAA,qBAAa,iBAAiB;IAGT,KAAK,EAAE,MAAM;IAFhC,OAAO,SAAM;gBAEM,KAAK,EAAE,MAAM;IAGhC,IAAI,GAAG,IAAI,MAAM,CAEhB;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification-kind.d.ts","sourceRoot":"","sources":["../../../src/lib/notification-kind.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,eAAO,MAAM,YAAY,IAAK,CAAC;AAE/B,eAAO,MAAM,qBAAqB;;;;CAIjC,CAAC"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { Observable } from 'rxjs';
|
|
2
|
-
import { TestMessages } from './types';
|
|
3
1
|
import { TestScheduler } from 'rxjs/testing';
|
|
4
2
|
export declare class Scheduler {
|
|
5
3
|
static instance: TestScheduler | null;
|
|
6
4
|
static init(): void;
|
|
7
5
|
static get(): TestScheduler;
|
|
8
6
|
static reset(): void;
|
|
9
|
-
static materializeInnerObservable(observable: Observable<any>, outerFrame: number): TestMessages;
|
|
10
7
|
}
|
|
8
|
+
//# sourceMappingURL=scheduler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../../../src/lib/scheduler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,qBAAa,SAAS;IACpB,OAAc,QAAQ,EAAE,aAAa,GAAG,IAAI,CAAC;WAE/B,IAAI,IAAI,IAAI;WAIZ,GAAG,IAAI,aAAa;WAOpB,KAAK,IAAI,IAAI;CAG5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strip-alignment-chars.d.ts","sourceRoot":"","sources":["../../../src/lib/strip-alignment-chars.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE3D"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { TestScheduler } from 'rxjs/testing';
|
|
2
|
+
export type ColdObservable<T> = ReturnType<typeof TestScheduler.prototype.createColdObservable<T>>;
|
|
3
|
+
export type HotObservable<T> = ReturnType<typeof TestScheduler.prototype.createHotObservable<T>>;
|
|
4
|
+
export type TestObservable<T> = ColdObservable<T> | HotObservable<T>;
|
|
2
5
|
/**
|
|
3
6
|
* Exported return type of TestMessage[] to avoid importing internal APIs.
|
|
4
7
|
*/
|
|
@@ -7,3 +10,4 @@ export type TestMessages = ReturnType<typeof TestScheduler.parseMarbles>;
|
|
|
7
10
|
* Exported return type of SubscriptionLog to avoid importing internal APIs.
|
|
8
11
|
*/
|
|
9
12
|
export type SubscriptionLog = ReturnType<typeof TestScheduler.parseMarblesAsSubscriptions>;
|
|
13
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,UAAU,CAAC,OAAO,aAAa,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC;AAEnG,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,UAAU,CAAC,OAAO,aAAa,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC;AAEjG,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,cAAc,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;AAErE;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,YAAY,CAAC,CAAC;AAEzE;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,2BAA2B,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@granito/vitest-marbles",
|
|
3
|
-
"version": "1.0.0-dev.
|
|
3
|
+
"version": "1.0.0-dev.4",
|
|
4
4
|
"description": "Marble testing helpers library for RxJs and Vitest",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,38 +20,63 @@
|
|
|
20
20
|
"node": ">=22",
|
|
21
21
|
"npm": ">=10"
|
|
22
22
|
},
|
|
23
|
-
"scripts": {
|
|
24
|
-
"build": "tsc",
|
|
25
|
-
"test": "vitest --no-watch"
|
|
26
|
-
},
|
|
27
|
-
"publishConfig": {
|
|
28
|
-
"access": "public",
|
|
29
|
-
"tag": "latest"
|
|
30
|
-
},
|
|
31
23
|
"files": [
|
|
32
|
-
"
|
|
24
|
+
"./"
|
|
33
25
|
],
|
|
34
26
|
"type": "module",
|
|
27
|
+
"main": "./index.js",
|
|
28
|
+
"module": "./index.js",
|
|
29
|
+
"types": "./index.d.ts",
|
|
35
30
|
"exports": {
|
|
36
|
-
"./package.json":
|
|
37
|
-
"default": "./package.json"
|
|
38
|
-
},
|
|
31
|
+
"./package.json": "./package.json",
|
|
39
32
|
".": {
|
|
40
|
-
"types": "./
|
|
41
|
-
"
|
|
33
|
+
"types": "./index.d.ts",
|
|
34
|
+
"import": "./index.js",
|
|
35
|
+
"default": "./index.js"
|
|
42
36
|
}
|
|
43
37
|
},
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public",
|
|
40
|
+
"tag": "latest"
|
|
41
|
+
},
|
|
47
42
|
"devDependencies": {
|
|
48
|
-
"
|
|
43
|
+
"@nx/esbuild": "22.1.2",
|
|
44
|
+
"@nx/vitest": "22.1.2",
|
|
45
|
+
"@vitest/coverage-v8": "^4.0.14",
|
|
46
|
+
"esbuild": "^0.27.0",
|
|
47
|
+
"jsdom": "~22.1.0",
|
|
48
|
+
"nx": "22.1.2",
|
|
49
49
|
"rxjs": "^7.8.2",
|
|
50
|
-
"
|
|
51
|
-
"
|
|
50
|
+
"tslib": "^2.3.0",
|
|
51
|
+
"typescript": "~5.9.2",
|
|
52
|
+
"vite": "^7.2.6",
|
|
53
|
+
"vitest": "^4.0.0"
|
|
52
54
|
},
|
|
53
55
|
"peerDependencies": {
|
|
54
56
|
"rxjs": "^7.0.0",
|
|
55
57
|
"vitest": "^4.0.0"
|
|
58
|
+
},
|
|
59
|
+
"nx": {
|
|
60
|
+
"targets": {
|
|
61
|
+
"build": {
|
|
62
|
+
"executor": "@nx/esbuild:esbuild",
|
|
63
|
+
"outputs": [
|
|
64
|
+
"{options.outputPath}"
|
|
65
|
+
],
|
|
66
|
+
"options": {
|
|
67
|
+
"outputPath": "dist/vitest-marbles",
|
|
68
|
+
"main": "src/index.ts",
|
|
69
|
+
"tsConfig": "tsconfig.lib.json",
|
|
70
|
+
"format": [
|
|
71
|
+
"esm"
|
|
72
|
+
],
|
|
73
|
+
"declarationRootDir": "src",
|
|
74
|
+
"assets": [
|
|
75
|
+
"LICENSE",
|
|
76
|
+
"README.md"
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
56
81
|
}
|
|
57
82
|
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { ColdObservable } from './src/rxjs/cold-observable';
|
|
2
|
-
import { HotObservable } from './src/rxjs/hot-observable';
|
|
3
|
-
import { Subscription } from 'rxjs';
|
|
4
|
-
export type ObservableWithSubscriptions = ColdObservable | HotObservable;
|
|
5
|
-
export { Scheduler } from './src/rxjs/scheduler';
|
|
6
|
-
interface CustomMatchers<R = unknown> {
|
|
7
|
-
toBeObservable(observable: ObservableWithSubscriptions): R;
|
|
8
|
-
toHaveSubscriptions(marbles: string | string[]): R;
|
|
9
|
-
toHaveNoSubscriptions(): R;
|
|
10
|
-
toBeMarble(marble: string): R;
|
|
11
|
-
toSatisfyOnFlush(func: () => void): R;
|
|
12
|
-
}
|
|
13
|
-
declare module 'vitest' {
|
|
14
|
-
interface Matchers<T = any> extends CustomMatchers<T> {
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
export declare function hot(marbles: string, values?: object, error?: object): HotObservable;
|
|
18
|
-
export declare function cold(marbles: string, values?: object, error?: object): ColdObservable;
|
|
19
|
-
export declare function time(marbles: string): number;
|
|
20
|
-
export declare function schedule(work: () => void, delay: number): Subscription;
|
package/dist/index.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { ColdObservable } from './src/rxjs/cold-observable';
|
|
2
|
-
import { HotObservable } from './src/rxjs/hot-observable';
|
|
3
|
-
import { Scheduler } from './src/rxjs/scheduler';
|
|
4
|
-
import { stripAlignmentChars } from './src/rxjs/strip-alignment-chars';
|
|
5
|
-
import { TestScheduler } from 'rxjs/testing';
|
|
6
|
-
export { Scheduler } from './src/rxjs/scheduler';
|
|
7
|
-
export function hot(marbles, values, error) {
|
|
8
|
-
return new HotObservable(stripAlignmentChars(marbles), values, error);
|
|
9
|
-
}
|
|
10
|
-
export function cold(marbles, values, error) {
|
|
11
|
-
return new ColdObservable(stripAlignmentChars(marbles), values, error);
|
|
12
|
-
}
|
|
13
|
-
export function time(marbles) {
|
|
14
|
-
return Scheduler.get().createTime(stripAlignmentChars(marbles));
|
|
15
|
-
}
|
|
16
|
-
export function schedule(work, delay) {
|
|
17
|
-
return Scheduler.get().schedule(work, delay);
|
|
18
|
-
}
|
|
19
|
-
const dummyResult = {
|
|
20
|
-
message: () => '',
|
|
21
|
-
pass: true,
|
|
22
|
-
};
|
|
23
|
-
expect.extend({
|
|
24
|
-
toHaveSubscriptions(actual, marbles) {
|
|
25
|
-
const sanitizedMarbles = Array.isArray(marbles) ? marbles.map(stripAlignmentChars) : stripAlignmentChars(marbles);
|
|
26
|
-
Scheduler.get().expectSubscriptions(actual.getSubscriptions()).toBe(sanitizedMarbles);
|
|
27
|
-
return dummyResult;
|
|
28
|
-
},
|
|
29
|
-
toHaveNoSubscriptions(actual) {
|
|
30
|
-
Scheduler.get().expectSubscriptions(actual.getSubscriptions()).toBe([]);
|
|
31
|
-
return dummyResult;
|
|
32
|
-
},
|
|
33
|
-
toBeObservable(actual, expected) {
|
|
34
|
-
Scheduler.get().expectObservable(actual).toBe(expected.marbles, expected.values, expected.error);
|
|
35
|
-
return dummyResult;
|
|
36
|
-
},
|
|
37
|
-
toBeMarble(actual, marbles) {
|
|
38
|
-
Scheduler.get().expectObservable(actual).toBe(stripAlignmentChars(marbles));
|
|
39
|
-
return dummyResult;
|
|
40
|
-
},
|
|
41
|
-
toSatisfyOnFlush(actual, func) {
|
|
42
|
-
Scheduler.get().expectObservable(actual);
|
|
43
|
-
const flushTests = Scheduler.get()['flushTests'];
|
|
44
|
-
flushTests[flushTests.length - 1].ready = true;
|
|
45
|
-
onFlush.push(func);
|
|
46
|
-
return dummyResult;
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
let onFlush = [];
|
|
50
|
-
beforeEach(() => {
|
|
51
|
-
Scheduler.init();
|
|
52
|
-
onFlush = [];
|
|
53
|
-
});
|
|
54
|
-
afterEach(() => {
|
|
55
|
-
Scheduler.get().run(() => TestScheduler.frameTimeFactor = 10);
|
|
56
|
-
while (onFlush.length > 0)
|
|
57
|
-
onFlush.shift()?.();
|
|
58
|
-
Scheduler.reset();
|
|
59
|
-
});
|
|
60
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAI7C,OAAO,EAAE,SAAS,EAAE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,OAAO,CAAC,KAAK,EAAE,EAAE,EAAE,CAAC;IAEtB,SAAS,CAAC,KAAK,EAAE,CAAC;AACpB,CAAC,CAAC,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export var MarblesGlossary;
|
|
2
|
-
(function (MarblesGlossary) {
|
|
3
|
-
MarblesGlossary["Completion"] = "|";
|
|
4
|
-
MarblesGlossary["Error"] = "#";
|
|
5
|
-
MarblesGlossary["TimeFrame"] = "-";
|
|
6
|
-
MarblesGlossary["Subscription"] = "^";
|
|
7
|
-
MarblesGlossary["Unsubscription"] = "!";
|
|
8
|
-
MarblesGlossary["GroupStart"] = "(";
|
|
9
|
-
MarblesGlossary["GroupEnd"] = ")";
|
|
10
|
-
})(MarblesGlossary || (MarblesGlossary = {}));
|
|
11
|
-
//# sourceMappingURL=marbles-glossary.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"marbles-glossary.js","sourceRoot":"","sources":["../../src/marbles-glossary.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,eAQX;AARD,WAAY,eAAe;IACzB,mCAAgB,CAAA;IAChB,8BAAW,CAAA;IACX,kCAAe,CAAA;IACf,qCAAkB,CAAA;IAClB,uCAAoB,CAAA;IACpB,mCAAgB,CAAA;IAChB,iCAAc,CAAA;AAChB,CAAC,EARW,eAAe,KAAf,eAAe,QAQ1B"}
|
package/dist/src/marblizer.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { MarblesGlossary } from './marbles-glossary';
|
|
2
|
-
import { NotificationEvent } from './notification-event';
|
|
3
|
-
import { NotificationKindChars, ValueLiteral } from './notification-kind';
|
|
4
|
-
const frameStep = 10;
|
|
5
|
-
export class Marblizer {
|
|
6
|
-
static marblize(messages) {
|
|
7
|
-
const emissions = Marblizer.getNotificationEvents(messages);
|
|
8
|
-
let marbles = '';
|
|
9
|
-
for (let i = 0, prevEndFrame = 0; i < emissions.length; prevEndFrame = emissions[i].end, i++)
|
|
10
|
-
marbles = `${marbles}${MarblesGlossary.TimeFrame.repeat(emissions[i].start - prevEndFrame) + emissions[i].marbles}`;
|
|
11
|
-
return marbles;
|
|
12
|
-
}
|
|
13
|
-
static marblizeSubscriptions(logs) {
|
|
14
|
-
return logs.map(log => this.marblizeLogEntry(log.subscribedFrame / frameStep, MarblesGlossary.Subscription) +
|
|
15
|
-
this.marblizeLogEntry((log.unsubscribedFrame - log.subscribedFrame) / frameStep - 1, MarblesGlossary.Unsubscription));
|
|
16
|
-
}
|
|
17
|
-
static marblizeLogEntry(logPoint, symbol) {
|
|
18
|
-
return logPoint !== Infinity ? MarblesGlossary.TimeFrame.repeat(logPoint) + symbol : '';
|
|
19
|
-
}
|
|
20
|
-
static getNotificationEvents(messages) {
|
|
21
|
-
const framesToEmissions = messages.reduce((result, message) => {
|
|
22
|
-
if (!result[message.frame])
|
|
23
|
-
result[message.frame] = new NotificationEvent(message.frame / frameStep);
|
|
24
|
-
const event = result[message.frame];
|
|
25
|
-
event.marbles += Marblizer.extractMarble(message);
|
|
26
|
-
return result;
|
|
27
|
-
}, {});
|
|
28
|
-
const events = Object
|
|
29
|
-
.keys(framesToEmissions)
|
|
30
|
-
.map(frame => framesToEmissions[Number(frame)]);
|
|
31
|
-
Marblizer.encloseGroupEvents(events);
|
|
32
|
-
return events;
|
|
33
|
-
}
|
|
34
|
-
static extractMarble(message) {
|
|
35
|
-
let marble = NotificationKindChars[message.notification.kind];
|
|
36
|
-
if (marble === ValueLiteral)
|
|
37
|
-
marble = message.notification.value;
|
|
38
|
-
return marble;
|
|
39
|
-
}
|
|
40
|
-
static encloseGroupEvents(events) {
|
|
41
|
-
events.forEach(event => {
|
|
42
|
-
if (event.marbles.length > 1)
|
|
43
|
-
event.marbles = `${MarblesGlossary.GroupStart}${event.marbles}${MarblesGlossary.GroupEnd}`;
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
//# sourceMappingURL=marblizer.js.map
|
|
@@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O,CAAC,KAAK,CAAC,EAAE;YACrB,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;gBAC1B,KAAK,CAAC,OAAO,GAAG,GAAG,eAAe,CAAC,UAAU,GAAG,KAAK,CAAC,OAAO,GAAG,eAAe,CAAC,QAAQ,EAAE,CAAC;QAC/F,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"notification-event.js","sourceRoot":"","sources":["../../src/notification-event.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,iBAAiB;IAGT;IAFnB,OAAO,GAAG,EAAE,CAAC;IAEb,YAAmB,KAAa;QAAb,UAAK,GAAL,KAAK,CAAQ;IAChC,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC1C,CAAC;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"notification-kind.js","sourceRoot":"","sources":["../../src/notification-kind.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAC;AAE/B,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,CAAC,EAAE,YAAY;IACf,CAAC,EAAE,eAAe,CAAC,UAAU;IAC7B,CAAC,EAAE,eAAe,CAAC,KAAK;CACzB,CAAC"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { SubscriptionLog, TestMessages } from './types';
|
|
2
|
-
import '../vitest/custom-matchers';
|
|
3
|
-
export type MessageOrSubscription = TestMessages | SubscriptionLog[];
|
|
4
|
-
export declare function assertDeepEqual(actual: MessageOrSubscription, expected: MessageOrSubscription): void;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import '../vitest/custom-matchers';
|
|
2
|
-
function expectedIsSubscriptionLogArray(actual, expected) {
|
|
3
|
-
return actual.length === 0 && expected.length === 0 ||
|
|
4
|
-
expected.length !== 0 && expected[0].subscribedFrame !== undefined;
|
|
5
|
-
}
|
|
6
|
-
function actualIsSubscriptionsAndExpectedIsEmpty(actual, expected) {
|
|
7
|
-
return expected.length === 0 && actual.length !== 0 && actual[0].subscribedFrame !== undefined;
|
|
8
|
-
}
|
|
9
|
-
export function assertDeepEqual(actual, expected) {
|
|
10
|
-
if (!expected)
|
|
11
|
-
return;
|
|
12
|
-
if (actualIsSubscriptionsAndExpectedIsEmpty(actual, expected))
|
|
13
|
-
expect(actual).toHaveEmptySubscriptions();
|
|
14
|
-
else if (expectedIsSubscriptionLogArray(actual, expected))
|
|
15
|
-
expect(actual).toBeSubscriptions(expected);
|
|
16
|
-
else
|
|
17
|
-
expect(actual).toBeNotifications(expected);
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=assert-deep-equal.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"assert-deep-equal.js","sourceRoot":"","sources":["../../../src/rxjs/assert-deep-equal.ts"],"names":[],"mappings":"AACA,OAAO,2BAA2B,CAAC;AAInC,SAAS,8BAA8B,CAAC,MAA6B,EACnE,QAA+B;IAC/B,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QACjD,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAK,QAAQ,CAAC,CAAC,CAAS,CAAC,eAAe,KAAK,SAAS,CAAC;AAChF,CAAC;AAED,SAAS,uCAAuC,CAAC,MAA6B,EAC5E,QAA+B;IAC/B,OAAO,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAK,MAAM,CAAC,CAAC,CAAS,CAAC,eAAe,KAAK,SAAS,CAAC;AAC1G,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,MAA6B,EAAE,QAA+B;IAC5F,IAAI,CAAC,QAAQ;QACX,OAAO;IAET,IAAI,uCAAuC,CAAC,MAAM,EAAE,QAAQ,CAAC;QAC3D,MAAM,CAAC,MAAM,CAAC,CAAC,wBAAwB,EAAE,CAAC;SACvC,IAAI,8BAA8B,CAAC,MAAM,EAAE,QAAQ,CAAC;QACvD,MAAM,CAAC,MAAM,CAAC,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;;QAE3C,MAAM,CAAC,MAAM,CAAC,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Observable } from 'rxjs';
|
|
2
|
-
import { TestScheduler } from 'rxjs/testing';
|
|
3
|
-
import { SubscriptionLog } from './types';
|
|
4
|
-
export declare class ColdObservable extends Observable<any> {
|
|
5
|
-
marbles: string;
|
|
6
|
-
values?: Record<string, any> | undefined;
|
|
7
|
-
error?: any | undefined;
|
|
8
|
-
source: ReturnType<TestScheduler['createColdObservable']>;
|
|
9
|
-
constructor(marbles: string, values?: Record<string, any> | undefined, error?: any | undefined);
|
|
10
|
-
getSubscriptions(): SubscriptionLog[];
|
|
11
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Observable } from 'rxjs';
|
|
2
|
-
import { Scheduler } from './scheduler';
|
|
3
|
-
export class ColdObservable extends Observable {
|
|
4
|
-
marbles;
|
|
5
|
-
values;
|
|
6
|
-
error;
|
|
7
|
-
source;
|
|
8
|
-
constructor(marbles, values, error) {
|
|
9
|
-
super();
|
|
10
|
-
this.marbles = marbles;
|
|
11
|
-
this.values = values;
|
|
12
|
-
this.error = error;
|
|
13
|
-
this.source = Scheduler.get().createColdObservable(marbles, values, error);
|
|
14
|
-
}
|
|
15
|
-
getSubscriptions() {
|
|
16
|
-
return this.source.subscriptions;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=cold-observable.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cold-observable.js","sourceRoot":"","sources":["../../../src/rxjs/cold-observable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAGlC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,OAAO,cAAe,SAAQ,UAAe;IAG9B;IAAwB;IAAqC;IAFvE,MAAM,CAAoD;IAEnE,YAAmB,OAAe,EAAS,MAA4B,EAAS,KAAW;QACzF,KAAK,EAAE,CAAC;QADS,YAAO,GAAP,OAAO,CAAQ;QAAS,WAAM,GAAN,MAAM,CAAsB;QAAS,UAAK,GAAL,KAAK,CAAM;QAGzF,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,EAAE,CAAC,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAC7E,CAAC;IAED,gBAAgB;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;IACnC,CAAC;CACF"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Observable } from 'rxjs';
|
|
2
|
-
import { TestScheduler } from 'rxjs/testing';
|
|
3
|
-
import { SubscriptionLog } from './types';
|
|
4
|
-
export declare class HotObservable extends Observable<any> {
|
|
5
|
-
marbles: string;
|
|
6
|
-
values?: Record<string, any> | undefined;
|
|
7
|
-
error?: any | undefined;
|
|
8
|
-
source: ReturnType<TestScheduler['createHotObservable']>;
|
|
9
|
-
constructor(marbles: string, values?: Record<string, any> | undefined, error?: any | undefined);
|
|
10
|
-
getSubscriptions(): SubscriptionLog[];
|
|
11
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Observable } from 'rxjs';
|
|
2
|
-
import { Scheduler } from './scheduler';
|
|
3
|
-
export class HotObservable extends Observable {
|
|
4
|
-
marbles;
|
|
5
|
-
values;
|
|
6
|
-
error;
|
|
7
|
-
source;
|
|
8
|
-
constructor(marbles, values, error) {
|
|
9
|
-
super();
|
|
10
|
-
this.marbles = marbles;
|
|
11
|
-
this.values = values;
|
|
12
|
-
this.error = error;
|
|
13
|
-
this.source = Scheduler.get().createHotObservable(marbles, values, error);
|
|
14
|
-
}
|
|
15
|
-
getSubscriptions() {
|
|
16
|
-
return this.source.subscriptions;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=hot-observable.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hot-observable.js","sourceRoot":"","sources":["../../../src/rxjs/hot-observable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAGlC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,OAAO,aAAc,SAAQ,UAAe;IAG7B;IAAwB;IAAqC;IAFvE,MAAM,CAAmD;IAElE,YAAmB,OAAe,EAAS,MAA4B,EAAS,KAAW;QACzF,KAAK,EAAE,CAAC;QADS,YAAO,GAAP,OAAO,CAAQ;QAAS,WAAM,GAAN,MAAM,CAAsB;QAAS,UAAK,GAAL,KAAK,CAAM;QAGzF,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,EAAE,CAAC,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAC5E,CAAC;IAED,gBAAgB;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;IACnC,CAAC;CACF"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { TestScheduler } from 'rxjs/testing';
|
|
2
|
-
import { assertDeepEqual } from './assert-deep-equal';
|
|
3
|
-
export class Scheduler {
|
|
4
|
-
static instance;
|
|
5
|
-
static init() {
|
|
6
|
-
Scheduler.instance = new TestScheduler(assertDeepEqual);
|
|
7
|
-
}
|
|
8
|
-
static get() {
|
|
9
|
-
if (Scheduler.instance)
|
|
10
|
-
return Scheduler.instance;
|
|
11
|
-
throw new Error('Scheduler is not initialized');
|
|
12
|
-
}
|
|
13
|
-
static reset() {
|
|
14
|
-
Scheduler.instance = null;
|
|
15
|
-
}
|
|
16
|
-
static materializeInnerObservable(observable, outerFrame) {
|
|
17
|
-
const scheduler = Scheduler.get();
|
|
18
|
-
// @ts-expect-error to avoid code duplication
|
|
19
|
-
return scheduler.materializeInnerObservable(observable, outerFrame);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=scheduler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scheduler.js","sourceRoot":"","sources":["../../../src/rxjs/scheduler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,MAAM,OAAO,SAAS;IACb,MAAM,CAAC,QAAQ,CAAuB;IAEtC,MAAM,CAAC,IAAI;QAChB,SAAS,CAAC,QAAQ,GAAG,IAAI,aAAa,CAAC,eAAe,CAAC,CAAC;IAC1D,CAAC;IAEM,MAAM,CAAC,GAAG;QACf,IAAI,SAAS,CAAC,QAAQ;YACpB,OAAO,SAAS,CAAC,QAAQ,CAAC;QAE5B,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAClD,CAAC;IAEM,MAAM,CAAC,KAAK;QACjB,SAAS,CAAC,QAAQ,GAAG,IAAI,CAAC;IAC5B,CAAC;IAEM,MAAM,CAAC,0BAA0B,CAAC,UAA2B,EAAE,UAAkB;QACtF,MAAM,SAAS,GAAG,SAAS,CAAC,GAAG,EAAE,CAAC;QAElC,6CAA6C;QAC7C,OAAO,SAAS,CAAC,0BAA0B,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IACtE,CAAC;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"strip-alignment-chars.js","sourceRoot":"","sources":["../../../src/rxjs/strip-alignment-chars.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,mBAAmB,CAAC,OAAe;IACjD,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACpC,CAAC"}
|
package/dist/src/rxjs/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/rxjs/types.ts"],"names":[],"mappings":""}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { SubscriptionLog, TestMessages } from '../rxjs/types';
|
|
2
|
-
import { MatchersObject } from '@vitest/expect';
|
|
3
|
-
interface CustomMatchers<R = unknown> {
|
|
4
|
-
toBeNotifications: (messages: TestMessages) => R;
|
|
5
|
-
toBeSubscriptions: (subscriptions: SubscriptionLog[]) => R;
|
|
6
|
-
toHaveEmptySubscriptions: () => R;
|
|
7
|
-
}
|
|
8
|
-
export declare const customTestMatchers: MatchersObject;
|
|
9
|
-
declare module 'vitest' {
|
|
10
|
-
interface Matchers<T = any> extends CustomMatchers<T> {
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
export {};
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { Marblizer } from '../marblizer';
|
|
2
|
-
export const customTestMatchers = {
|
|
3
|
-
toBeNotifications(actual, expected) {
|
|
4
|
-
let actualMarble = actual;
|
|
5
|
-
let expectedMarble = expected;
|
|
6
|
-
if (canMarblize(actual, expected)) {
|
|
7
|
-
actualMarble = Marblizer.marblize(actual);
|
|
8
|
-
expectedMarble = Marblizer.marblize(expected);
|
|
9
|
-
}
|
|
10
|
-
const pass = this.equals(actualMarble, expectedMarble);
|
|
11
|
-
const message = pass ? () => this.utils.matcherHint('.not.toBeNotifications') +
|
|
12
|
-
'\n\n' +
|
|
13
|
-
`Expected notifications to not be:\n` +
|
|
14
|
-
` ${this.utils.printExpected(expectedMarble)}\n` +
|
|
15
|
-
`But got:\n` +
|
|
16
|
-
` ${this.utils.printReceived(actualMarble)}` : () => {
|
|
17
|
-
const diffString = this.utils.diff(expectedMarble, actualMarble, {
|
|
18
|
-
expand: true,
|
|
19
|
-
});
|
|
20
|
-
return (this.utils.matcherHint('.toBeNotifications') +
|
|
21
|
-
'\n\n' +
|
|
22
|
-
`Expected notifications to be:\n` +
|
|
23
|
-
` ${this.utils.printExpected(expectedMarble)}\n` +
|
|
24
|
-
`But got:\n` +
|
|
25
|
-
` ${this.utils.printReceived(actualMarble)}` +
|
|
26
|
-
(diffString ? `\n\nDifference:\n\n${diffString}` : ''));
|
|
27
|
-
};
|
|
28
|
-
return {
|
|
29
|
-
pass,
|
|
30
|
-
message
|
|
31
|
-
};
|
|
32
|
-
},
|
|
33
|
-
toBeSubscriptions(actual, expected) {
|
|
34
|
-
const actualMarbleArray = Marblizer.marblizeSubscriptions(actual);
|
|
35
|
-
const expectedMarbleArray = Marblizer.marblizeSubscriptions(expected);
|
|
36
|
-
const pass = subscriptionsPass(actualMarbleArray, expectedMarbleArray);
|
|
37
|
-
const message = pass ? () => this.utils.matcherHint('.not.toHaveSubscriptions') +
|
|
38
|
-
'\n\n' +
|
|
39
|
-
`Expected observable to not have the following subscription points:\n` +
|
|
40
|
-
` ${this.utils.printExpected(expectedMarbleArray)}\n` +
|
|
41
|
-
`But got:\n` +
|
|
42
|
-
` ${this.utils.printReceived(actualMarbleArray)}` : () => {
|
|
43
|
-
const diffString = this.utils.diff(expectedMarbleArray, actualMarbleArray, {
|
|
44
|
-
expand: true,
|
|
45
|
-
});
|
|
46
|
-
return (this.utils.matcherHint('.toHaveSubscriptions') +
|
|
47
|
-
'\n\n' +
|
|
48
|
-
`Expected observable to have the following subscription points:\n` +
|
|
49
|
-
` ${this.utils.printExpected(expectedMarbleArray)}\n` +
|
|
50
|
-
`But got:\n` +
|
|
51
|
-
` ${this.utils.printReceived(actualMarbleArray)}` +
|
|
52
|
-
(diffString ? `\n\nDifference:\n\n${diffString}` : ''));
|
|
53
|
-
};
|
|
54
|
-
return {
|
|
55
|
-
pass,
|
|
56
|
-
message
|
|
57
|
-
};
|
|
58
|
-
},
|
|
59
|
-
toHaveEmptySubscriptions(actual) {
|
|
60
|
-
const pass = !(actual && actual.length > 0);
|
|
61
|
-
let marbles;
|
|
62
|
-
if (actual && actual.length > 0)
|
|
63
|
-
marbles = Marblizer.marblizeSubscriptions(actual);
|
|
64
|
-
const message = pass ? () => this.utils.matcherHint('.not.toHaveNoSubscriptions') +
|
|
65
|
-
'\n\n' +
|
|
66
|
-
`Expected observable to have at least one subscription point, but got nothing` +
|
|
67
|
-
this.utils.printReceived('') : () => this.utils.matcherHint('.toHaveNoSubscriptions') +
|
|
68
|
-
'\n\n' +
|
|
69
|
-
`Expected observable to have no subscription points\n` +
|
|
70
|
-
`But got:\n` +
|
|
71
|
-
` ${this.utils.printReceived(marbles)}\n\n`;
|
|
72
|
-
return {
|
|
73
|
-
pass,
|
|
74
|
-
message
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
expect.extend(customTestMatchers);
|
|
79
|
-
function canMarblize(...messages) {
|
|
80
|
-
return messages.every(isMessagesMarblizable);
|
|
81
|
-
}
|
|
82
|
-
function isMessagesMarblizable(messages) {
|
|
83
|
-
return messages.every(({ notification }) => notification.kind === 'C' ||
|
|
84
|
-
(notification.kind === 'E' && notification.error === 'error') ||
|
|
85
|
-
(notification.kind === 'N' && isCharacter(notification.value)));
|
|
86
|
-
}
|
|
87
|
-
function isCharacter(value) {
|
|
88
|
-
return typeof value === 'string' && value.length === 1 || value !== undefined && JSON.stringify(value).length === 1;
|
|
89
|
-
}
|
|
90
|
-
function subscriptionsPass(actualMarbleArray, expectedMarbleArray) {
|
|
91
|
-
if (actualMarbleArray.length !== expectedMarbleArray.length) {
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
let pass = true;
|
|
95
|
-
for (const actualMarble of actualMarbleArray) {
|
|
96
|
-
if (!expectedMarbleArray.includes(actualMarble)) {
|
|
97
|
-
pass = false;
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return pass;
|
|
102
|
-
}
|
|
103
|
-
//# sourceMappingURL=custom-matchers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"custom-matchers.js","sourceRoot":"","sources":["../../../src/vitest/custom-matchers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAWzC,MAAM,CAAC,MAAM,kBAAkB,GAAmB;IAChD,iBAAiB,CAAC,MAAoB,EAAE,QAAsB;QAC5D,IAAI,YAAY,GAA0B,MAAM,CAAC;QACjD,IAAI,cAAc,GAA0B,QAAQ,CAAC;QAErD,IAAI,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,CAAC;YAClC,YAAY,GAAG,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YAC1C,cAAc,GAAG,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAChD,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;QACvD,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,CAC1B,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,wBAAwB,CAAC;YAChD,MAAM;YACN,qCAAqC;YACrC,KAAK,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,IAAI;YACjD,YAAY;YACZ,KAAK,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE;YACrD,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,EAAE,YAAY,EAAE;gBAC/D,MAAM,EAAE,IAAI;aACb,CAAC,CAAC;YAEH,OAAO,CACL,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,oBAAoB,CAAC;gBAC5C,MAAM;gBACN,iCAAiC;gBACjC,KAAK,IAAI,CAAC,KAAK,CAAC,aAAa,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