@granito/vitest-marbles 1.0.0-dev.5 → 1.0.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 CHANGED
@@ -4,7 +4,7 @@
4
4
  # Vitest Marbles
5
5
 
6
6
  A set of helper functions and [Vitest](http://vitest.dev/) matchers for
7
- [RxJs](https://rxjs.dev/)
7
+ [RxJS](https://rxjs.dev/)
8
8
  [marble testing](https://rxjs.dev/guide/testing/marble-testing).
9
9
  This library will help you to test your reactive code in easy and
10
10
  clean way.
@@ -12,7 +12,7 @@ clean way.
12
12
  # Features
13
13
 
14
14
  * Typescript;
15
- * easy to read error messages for subscriptions.
15
+ * easy to read error messages for subscription expectations.
16
16
 
17
17
  # Prerequisites
18
18
 
package/index.js CHANGED
@@ -41,7 +41,7 @@ ${diff}`;
41
41
  toBeSubscriptions(actualSubs, expectedSubs) {
42
42
  const actual = marblize(actualSubs);
43
43
  const expected = marblize(expectedSubs);
44
- const pass = subscriptionsPass(actual, expected);
44
+ const pass = sameSubscriptions(actual, expected);
45
45
  let message = "";
46
46
  if (!pass) {
47
47
  const diff = this.utils.diff(expected, actual, { expand: true });
@@ -62,10 +62,7 @@ ${diff}`;
62
62
  };
63
63
  },
64
64
  toHaveEmptySubscriptions(actual) {
65
- const pass = !(actual && actual.length > 0);
66
- let message = "";
67
- if (!pass)
68
- message = this.utils.matcherHint(".toHaveNoSubscriptions") + `
65
+ const message = this.utils.matcherHint(".toHaveNoSubscriptions") + `
69
66
 
70
67
  Expected observable to have no subscription points
71
68
  But got:
@@ -73,13 +70,13 @@ But got:
73
70
 
74
71
  `;
75
72
  return {
76
- pass,
73
+ pass: false,
77
74
  message: () => message
78
75
  };
79
76
  }
80
77
  };
81
78
  expect.extend(internalMatchers);
82
- function subscriptionsPass(actualMarbleArray, expectedMarbleArray) {
79
+ function sameSubscriptions(actualMarbleArray, expectedMarbleArray) {
83
80
  if (actualMarbleArray.length !== expectedMarbleArray.length)
84
81
  return false;
85
82
  for (const actualMarble of actualMarbleArray)
@@ -92,18 +89,20 @@ function subscriptionsPass(actualMarbleArray, expectedMarbleArray) {
92
89
  function assertDeepEqual(actual, expected) {
93
90
  if (!expected)
94
91
  return;
95
- if (actualIsSubscriptionsAndExpectedIsEmpty(actual, expected))
96
- expect(actual).toHaveEmptySubscriptions();
97
- else if (expectedIsSubscriptionLogArray(actual, expected))
98
- expect(actual).toBeSubscriptions(expected);
99
- else
100
- expect(actual).toBeNotifications(expected);
101
- }
102
- function actualIsSubscriptionsAndExpectedIsEmpty(actual, expected) {
103
- return expected.length === 0 && actual.length !== 0 && actual[0].subscribedFrame !== void 0;
92
+ if (expected.length !== 0) {
93
+ if (isSubscriptions(expected))
94
+ expect(actual).toBeSubscriptions(expected);
95
+ else
96
+ expect(actual).toBeNotifications(expected);
97
+ } else if (actual.length !== 0) {
98
+ if (isSubscriptions(actual))
99
+ expect(actual).toHaveEmptySubscriptions();
100
+ else
101
+ expect(actual).toBeNotifications([]);
102
+ }
104
103
  }
105
- function expectedIsSubscriptionLogArray(actual, expected) {
106
- return actual.length === 0 && expected.length === 0 || expected.length !== 0 && expected[0].subscribedFrame !== void 0;
104
+ function isSubscriptions(log) {
105
+ return log[0].subscribedFrame !== void 0;
107
106
  }
108
107
 
109
108
  // src/lib/scheduler.ts
@@ -118,7 +117,7 @@ var Scheduler = class _Scheduler {
118
117
  return _Scheduler.instance;
119
118
  }
120
119
  static reset() {
121
- _Scheduler.instance = null;
120
+ _Scheduler.instance = void 0;
122
121
  }
123
122
  };
124
123
 
@@ -1,4 +1,3 @@
1
- import { SubscriptionLog, TestMessages } from './types';
1
+ import { MessagesOrSubscriptions } from './types';
2
2
  import './internal-matchers';
3
- export type MessagesOrSubscriptions = TestMessages | SubscriptionLog[];
4
3
  export declare function assertDeepEqual(actual: MessagesOrSubscriptions, expected?: MessagesOrSubscriptions): void;
@@ -1,6 +1,6 @@
1
1
  import { TestScheduler } from 'rxjs/testing';
2
2
  export declare class Scheduler {
3
- static instance: TestScheduler | null;
3
+ static instance?: TestScheduler;
4
4
  static init(): void;
5
5
  static get(): TestScheduler;
6
6
  static reset(): void;
package/lib/types.d.ts CHANGED
@@ -10,3 +10,4 @@ export type TestMessages = ReturnType<typeof TestScheduler.parseMarbles>;
10
10
  * Exported return type of SubscriptionLog to avoid importing internal APIs.
11
11
  */
12
12
  export type SubscriptionLog = ReturnType<typeof TestScheduler.parseMarblesAsSubscriptions>;
13
+ export type MessagesOrSubscriptions = TestMessages | SubscriptionLog[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@granito/vitest-marbles",
3
- "version": "1.0.0-dev.5",
3
+ "version": "1.0.0",
4
4
  "description": "Marble testing helpers library for RxJs and Vitest",
5
5
  "repository": {
6
6
  "type": "git",
@@ -40,17 +40,17 @@
40
40
  "tag": "latest"
41
41
  },
42
42
  "devDependencies": {
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",
43
+ "@nx/esbuild": "22.2.3",
44
+ "@nx/vitest": "22.2.3",
45
+ "@vitest/coverage-v8": "^4.0.15",
46
+ "esbuild": "^0.27.1",
47
+ "jsdom": "~27.3.0",
48
+ "nx": "22.2.3",
49
49
  "rxjs": "^7.8.2",
50
- "tslib": "^2.3.0",
51
- "typescript": "~5.9.2",
52
- "vite": "^7.2.6",
53
- "vitest": "^4.0.0"
50
+ "tslib": "^2.8.1",
51
+ "typescript": "~5.9.3",
52
+ "vite": "^7.2.7",
53
+ "vitest": "^4.0.15"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "rxjs": "^7.0.0",