Skip to content

Commit

Permalink
fix(time): Support explicit durations.
Browse files Browse the repository at this point in the history
  • Loading branch information
cartant committed May 18, 2018
1 parent 604db04 commit 4a7ac1d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions fixtures/mocha/passing-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,5 +474,11 @@ describe("rxjs-marbles", () => {
const expected = m.cold("----(a|)");
m.expect(source.pipe(delay(duration, m.scheduler))).toBeObservable(expected);
}));

it("should support explicit durations in time", marbles((m) => {

const duration = m.time(" 2ms |");
expect(duration).to.equal(2);
}));
});
});
5 changes: 5 additions & 0 deletions source/context-run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ export class RunContext implements Context {

time(marbles: string): number {

const messages = TestScheduler.parseMarbles(marbles, undefined, undefined, undefined, true);
const complete = messages.find(({ notification }) => notification.kind === "C");
if (complete) {
return complete.frame;
}
return this.scheduler.createTime(marbles);
}
}
Expand Down

0 comments on commit 4a7ac1d

Please sign in to comment.