Skip to content

Commit

Permalink
Merge pull request #638 from kwonoj/wide-testmessage-type
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonoj committed May 18, 2021
2 parents 4931860 + 662210e commit d5e1983
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 9 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## [2.0.2](https://github.com/kwonoj/rx-sandbox/compare/v2.0.1...v2.0.2) (2021-05-18)


### Bug Fixes

* **testmessage:** wide notificationtype<T> ([b167aff](https://github.com/kwonoj/rx-sandbox/commit/b167affd8fb9e3a63e0cc747f362e9b78f85e2a1))



## [2.0.1](https://github.com/kwonoj/rx-sandbox/compare/v2.0.0...v2.0.1) (2021-05-18)


Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rx-sandbox",
"version": "2.0.1",
"version": "2.0.2",
"description": "Marble diagram DSL based test suite for RxJS 6",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
8 changes: 4 additions & 4 deletions spec/marbles/parseObservableMarble-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ describe('parseObservableMarble', () => {
const bMessages = [next(3, '3'), next(4, '4')];

const customValue = {
a: new ColdObservable(aMessages, null as any),
b: new ColdObservable(bMessages, null as any),
a: new ColdObservable(aMessages as any, null as any),
b: new ColdObservable(bMessages as any, null as any),
};

const messages = parseObservableMarble(marble, customValue, null, true);
Expand All @@ -66,8 +66,8 @@ describe('parseObservableMarble', () => {
const bMessages = [next(3, '3'), next(4, '4')];

const customValue = {
a: new ColdObservable<string>(aMessages, null as any),
b: new ColdObservable<string>(bMessages, null as any),
a: new ColdObservable<string>(aMessages as any, null as any),
b: new ColdObservable<string>(bMessages as any, null as any),
};

const messages = parseObservableMarble(marble, customValue, null, false);
Expand Down
13 changes: 12 additions & 1 deletion src/message/TestMessage.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
import { ObservableNotification } from 'rxjs';
import { SubscriptionLog } from '../utils/coreInternalImport';

/**
* Expanded structured type of `ObservableNotification<T>` since we can't narrow down
* TestMessage<T> to specific notification types, instead provide wide support
*/
interface NotificationType<T> {
kind: 'N' | 'E' | 'C';
value?: T;
error?: any;
}

/**
* Represents interface for single metadata value emitted by HotObservable<T> or ColdObservable<T>
*
*/
interface TestMessage<T = string> {
frame: number;
notification: ObservableNotification<T>;

notification: NotificationType<T>;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/scheduler/createTestScheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const getCreateColdObservable = (state: SandboxState) => {
const messages = Array.isArray(marbleValue)
? marbleValue
: (parseObservableMarble(marbleValue, value, error, false, frameTimeFactor, maxFrame) as any);
const observable = new ColdObservable<T>(messages as Array<TestMessage<T | Array<TestMessage<T>>>>, scheduler);
const observable = new ColdObservable<T>(messages, scheduler);
state.coldObservables.push(observable);
return observable;
}
Expand All @@ -75,7 +75,7 @@ const getCreateHotObservable = (state: SandboxState) => {
const messages = Array.isArray(marbleValue)
? marbleValue
: (parseObservableMarble(marbleValue, value, error, false, frameTimeFactor, maxFrame) as any);
const subject = new HotObservable<T>(messages as Array<TestMessage<T | Array<TestMessage<T>>>>, scheduler);
const subject = new HotObservable<T>(messages, scheduler);
state.hotObservables.push(subject);
return subject;
}
Expand Down

0 comments on commit d5e1983

Please sign in to comment.