Skip to content

Commit

Permalink
chore(tests2png): add exhaust PNG diagram
Browse files Browse the repository at this point in the history
Add test to draw PNG diagram for exhaust. Change painter.js to support exhaust (use case where an
inner Observable is emitted but never subscribed to).
  • Loading branch information
staltz authored and benlesh committed Jan 13, 2016
1 parent 2b707fa commit 2cc2035
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions spec/helpers/tests2png/painter.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,14 @@ function addGhostInnerInputs(inputStreams) {
var message = inputStream.messages[j];
if (isNestedStreamData(message) && typeof message.isGhost !== 'boolean') {
var referenceTime = message.frame;
if (!message.notification.value.subscription) {
// There was no subscription at all, so this nested Observable is ghost
message.isGhost = true;
message.notification.value.isGhost = true;
message.frame = referenceTime;
message.notification.value.subscription = { start: referenceTime, end: 0 };
continue;
}
var subscriptionTime = message.notification.value.subscription.start;
if (referenceTime !== subscriptionTime) {
message.isGhost = false;
Expand Down
10 changes: 10 additions & 0 deletions spec/operators/exhaust-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ var Observable = Rx.Observable;
var queueScheduler = Rx.Scheduler.queue;

describe('Observable.prototype.exhaust()', function () {
it.asDiagram('exhaust')('should handle a hot observable of hot observables', function () {
var x = cold( '--a---b---c--| ');
var y = cold( '---d--e---f---| ');
var z = cold( '---g--h---i---|');
var e1 = hot( '------x-------y-----z-------------|', { x: x, y: y, z: z });
var expected = '--------a---b---c------g--h---i---|';

expectObservable(e1.exhaust()).toBe(expected);
});

it('should switch to first immediately-scheduled inner Observable', function () {
var e1 = cold( '(ab|)');
var e1subs = '(^!)';
Expand Down

0 comments on commit 2cc2035

Please sign in to comment.