@granito/vitest-marbles 1.0.0-dev.3 → 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 +1 -1
- package/index.d.ts.map +1 -1
- package/index.js +253 -14
- 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/lib/marbles-glossary.d.ts.map +1 -1
- package/lib/marbles.d.ts +3 -17
- package/lib/marbles.d.ts.map +1 -1
- package/lib/marblizer.d.ts +1 -1
- package/lib/marblizer.d.ts.map +1 -1
- package/lib/matchers.d.ts +14 -0
- package/lib/matchers.d.ts.map +1 -0
- package/lib/notification-event.d.ts.map +1 -1
- package/lib/notification-kind.d.ts.map +1 -1
- package/lib/scheduler.d.ts +8 -0
- package/lib/scheduler.d.ts.map +1 -0
- package/lib/strip-alignment-chars.d.ts.map +1 -0
- package/lib/{rxjs/types.d.ts → types.d.ts} +3 -0
- package/lib/types.d.ts.map +1 -0
- package/package.json +4 -6
- package/lib/rxjs/assert-deep-equal.d.ts +0 -5
- package/lib/rxjs/assert-deep-equal.d.ts.map +0 -1
- package/lib/rxjs/cold-observable.d.ts +0 -12
- package/lib/rxjs/cold-observable.d.ts.map +0 -1
- package/lib/rxjs/hot-observable.d.ts +0 -12
- package/lib/rxjs/hot-observable.d.ts.map +0 -1
- package/lib/rxjs/scheduler.d.ts +0 -11
- package/lib/rxjs/scheduler.d.ts.map +0 -1
- package/lib/rxjs/strip-alignment-chars.d.ts.map +0 -1
- package/lib/rxjs/types.d.ts.map +0 -1
- package/lib/vitest/custom-matchers.d.ts +0 -14
- package/lib/vitest/custom-matchers.d.ts.map +0 -1
- /package/lib/{rxjs/strip-alignment-chars.d.ts → strip-alignment-chars.d.ts} +0 -0
package/index.d.ts
CHANGED
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["
|
|
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
CHANGED
|
@@ -1,37 +1,276 @@
|
|
|
1
|
-
|
|
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") + `
|
|
2
81
|
|
|
3
82
|
Expected notifications to not be:
|
|
4
|
-
${this.utils.printExpected(
|
|
83
|
+
${this.utils.printExpected(expectedMarble)}
|
|
5
84
|
But got:
|
|
6
|
-
${this.utils.printReceived(
|
|
85
|
+
${this.utils.printReceived(actualMarble)}` : () => {
|
|
86
|
+
const diffString = this.utils.diff(expectedMarble, actualMarble, {
|
|
87
|
+
expand: true
|
|
88
|
+
});
|
|
89
|
+
return this.utils.matcherHint(".toBeNotifications") + `
|
|
7
90
|
|
|
8
91
|
Expected notifications to be:
|
|
9
|
-
${this.utils.printExpected(
|
|
92
|
+
${this.utils.printExpected(expectedMarble)}
|
|
10
93
|
But got:
|
|
11
|
-
${this.utils.printReceived(
|
|
94
|
+
${this.utils.printReceived(actualMarble)}` + (diffString ? `
|
|
12
95
|
|
|
13
96
|
Difference:
|
|
14
97
|
|
|
15
|
-
${
|
|
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") + `
|
|
16
110
|
|
|
17
111
|
Expected observable to not have the following subscription points:
|
|
18
|
-
${this.utils.printExpected(
|
|
112
|
+
${this.utils.printExpected(expectedMarbleArray)}
|
|
19
113
|
But got:
|
|
20
|
-
${this.utils.printReceived(
|
|
114
|
+
${this.utils.printReceived(actualMarbleArray)}` : () => {
|
|
115
|
+
const diffString = this.utils.diff(expectedMarbleArray, actualMarbleArray, {
|
|
116
|
+
expand: true
|
|
117
|
+
});
|
|
118
|
+
return this.utils.matcherHint(".toHaveSubscriptions") + `
|
|
21
119
|
|
|
22
120
|
Expected observable to have the following subscription points:
|
|
23
|
-
${this.utils.printExpected(
|
|
121
|
+
${this.utils.printExpected(expectedMarbleArray)}
|
|
24
122
|
But got:
|
|
25
|
-
${this.utils.printReceived(
|
|
123
|
+
${this.utils.printReceived(actualMarbleArray)}` + (diffString ? `
|
|
26
124
|
|
|
27
125
|
Difference:
|
|
28
126
|
|
|
29
|
-
${
|
|
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") + `
|
|
30
140
|
|
|
31
|
-
Expected observable to have at least one subscription point, but got nothing
|
|
141
|
+
Expected observable to have at least one subscription point, but got nothing` + this.utils.printReceived("") : () => this.utils.matcherHint(".toHaveNoSubscriptions") + `
|
|
32
142
|
|
|
33
143
|
Expected observable to have no subscription points
|
|
34
144
|
But got:
|
|
35
|
-
${this.utils.printReceived(
|
|
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
|
+
}
|
|
36
227
|
|
|
37
|
-
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marbles-glossary.d.ts","sourceRoot":"","sources":["
|
|
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
CHANGED
|
@@ -1,21 +1,7 @@
|
|
|
1
|
-
import { ColdObservable } from './rxjs/cold-observable';
|
|
2
|
-
import { HotObservable } from './rxjs/hot-observable';
|
|
3
1
|
import { Subscription } from 'rxjs';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
toHaveSubscriptions(marbles: string | string[]): R;
|
|
8
|
-
toHaveNoSubscriptions(): R;
|
|
9
|
-
toBeMarble(marble: string): R;
|
|
10
|
-
toSatisfyOnFlush(func: () => void): R;
|
|
11
|
-
}
|
|
12
|
-
declare module 'vitest' {
|
|
13
|
-
interface Matchers<T = any> extends CustomMatchers<T> {
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
export declare function hot(marbles: string, values?: object, error?: object): HotObservable;
|
|
17
|
-
export declare function cold(marbles: string, values?: object, error?: object): ColdObservable;
|
|
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>;
|
|
18
5
|
export declare function time(marbles: string): number;
|
|
19
6
|
export declare function schedule(work: () => void, delay: number): Subscription;
|
|
20
|
-
export {};
|
|
21
7
|
//# sourceMappingURL=marbles.d.ts.map
|
package/lib/marbles.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marbles.d.ts","sourceRoot":"","sources":["
|
|
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"}
|
package/lib/marblizer.d.ts
CHANGED
|
@@ -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[];
|
package/lib/marblizer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marblizer.d.ts","sourceRoot":"","sources":["
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification-event.d.ts","sourceRoot":"","sources":["
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification-kind.d.ts","sourceRoot":"","sources":["
|
|
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"}
|
|
@@ -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
|
*/
|
|
@@ -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",
|
|
@@ -41,16 +41,15 @@
|
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@nx/esbuild": "22.1.2",
|
|
44
|
-
"@nx/js": "22.1.2",
|
|
45
44
|
"@nx/vitest": "22.1.2",
|
|
46
|
-
"@
|
|
45
|
+
"@vitest/coverage-v8": "^4.0.14",
|
|
47
46
|
"esbuild": "^0.27.0",
|
|
48
47
|
"jsdom": "~22.1.0",
|
|
49
48
|
"nx": "22.1.2",
|
|
50
49
|
"rxjs": "^7.8.2",
|
|
51
50
|
"tslib": "^2.3.0",
|
|
52
51
|
"typescript": "~5.9.2",
|
|
53
|
-
"vite": "^7.2.
|
|
52
|
+
"vite": "^7.2.6",
|
|
54
53
|
"vitest": "^4.0.0"
|
|
55
54
|
},
|
|
56
55
|
"peerDependencies": {
|
|
@@ -65,14 +64,13 @@
|
|
|
65
64
|
"{options.outputPath}"
|
|
66
65
|
],
|
|
67
66
|
"options": {
|
|
68
|
-
"outputPath": "dist",
|
|
67
|
+
"outputPath": "dist/vitest-marbles",
|
|
69
68
|
"main": "src/index.ts",
|
|
70
69
|
"tsConfig": "tsconfig.lib.json",
|
|
71
70
|
"format": [
|
|
72
71
|
"esm"
|
|
73
72
|
],
|
|
74
73
|
"declarationRootDir": "src",
|
|
75
|
-
"minify": true,
|
|
76
74
|
"assets": [
|
|
77
75
|
"LICENSE",
|
|
78
76
|
"README.md"
|
|
@@ -1,5 +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;
|
|
5
|
-
//# sourceMappingURL=assert-deep-equal.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"assert-deep-equal.d.ts","sourceRoot":"","sources":["../../../src/lib/rxjs/assert-deep-equal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,2BAA2B,CAAC;AAEnC,MAAM,MAAM,qBAAqB,GAAG,YAAY,GAAG,eAAe,EAAE,CAAC;AAarE,wBAAgB,eAAe,CAAC,MAAM,EAAE,qBAAqB,EAAE,QAAQ,EAAE,qBAAqB,QAU7F"}
|
|
@@ -1,12 +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
|
-
}
|
|
12
|
-
//# sourceMappingURL=cold-observable.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cold-observable.d.ts","sourceRoot":"","sources":["../../../src/lib/rxjs/cold-observable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG1C,qBAAa,cAAe,SAAQ,UAAU,CAAC,GAAG,CAAC;IAG9B,OAAO,EAAE,MAAM;IAAS,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAAS,KAAK,CAAC,EAAE,GAAG;IAFlF,MAAM,EAAE,UAAU,CAAC,aAAa,CAAC,sBAAsB,CAAC,CAAC,CAAC;gBAEhD,OAAO,EAAE,MAAM,EAAS,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,YAAA,EAAS,KAAK,CAAC,EAAE,GAAG,YAAA;IAM3F,gBAAgB,IAAI,eAAe,EAAE;CAGtC"}
|
|
@@ -1,12 +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
|
-
}
|
|
12
|
-
//# sourceMappingURL=hot-observable.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hot-observable.d.ts","sourceRoot":"","sources":["../../../src/lib/rxjs/hot-observable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG1C,qBAAa,aAAc,SAAQ,UAAU,CAAC,GAAG,CAAC;IAG7B,OAAO,EAAE,MAAM;IAAS,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAAS,KAAK,CAAC,EAAE,GAAG;IAFlF,MAAM,EAAE,UAAU,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC,CAAC;gBAE/C,OAAO,EAAE,MAAM,EAAS,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,YAAA,EAAS,KAAK,CAAC,EAAE,GAAG,YAAA;IAM3F,gBAAgB,IAAI,eAAe,EAAE;CAGtC"}
|
package/lib/rxjs/scheduler.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Observable } from 'rxjs';
|
|
2
|
-
import { TestMessages } from './types';
|
|
3
|
-
import { TestScheduler } from 'rxjs/testing';
|
|
4
|
-
export declare class Scheduler {
|
|
5
|
-
static instance: TestScheduler | null;
|
|
6
|
-
static init(): void;
|
|
7
|
-
static get(): TestScheduler;
|
|
8
|
-
static reset(): void;
|
|
9
|
-
static materializeInnerObservable(observable: Observable<any>, outerFrame: number): TestMessages;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=scheduler.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../../../src/lib/rxjs/scheduler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,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;WAIb,0BAA0B,CAAC,UAAU,EAAE,UAAU,CAAC,GAAG,CAAC,EAAE,UAAU,EAAE,MAAM,GAAG,YAAY;CAMxG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"strip-alignment-chars.d.ts","sourceRoot":"","sources":["../../../src/lib/rxjs/strip-alignment-chars.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,UAElD"}
|
package/lib/rxjs/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/rxjs/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C;;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"}
|
|
@@ -1,14 +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 {};
|
|
14
|
-
//# sourceMappingURL=custom-matchers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"custom-matchers.d.ts","sourceRoot":"","sources":["../../../src/lib/vitest/custom-matchers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE9D,OAAO,EAAqB,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEnE,UAAU,cAAc,CAAC,CAAC,GAAG,OAAO;IAClC,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,kBAAkB,EAAE,cA4FhC,CAAA;AAKD,OAAO,QAAQ,QAAQ,CAAC;IACtB,UAAU,QAAQ,CAAC,CAAC,GAAG,GAAG,CAAE,SAAQ,cAAc,CAAC,CAAC,CAAC;KACpD;CACF"}
|
|
File without changes
|