Rx.ReactiveTest
class
This class contains test utility methods such as create notifications for testing purposes.
Location
- rx.testing.js
ReactiveTest Class Methods
ReactiveTest Class Fields
ReactiveTest Class Methods
Rx.ReactiveTest.onCompleted(ticks)
Factory method for an OnCompleted notification record at a given time.
Arguments
ticks
(Number): Recorded virtual time the OnCompleted notification occurs.
Returns
(Recorded): OnCompleted notification.
Example
var onCompleted = Rx.ReactiveTest.onCompleted;
var scheduler = new Rx.TestScheduler();
var xs = scheduler.createHotObservable(
onCompleted(260)
);
var res = scheduler.startWithCreate(function () {
return xs.map(function (x) { return x; });
});
// Write custom assertion
collectionAssert(res, [
onCompleted(260)
]);
Location
- rx.testing.js
Rx.ReactiveTest.onError(ticks, exception)
Factory method for an OnError notification record at a given time with a given error.
Arguments
ticks
(Number): Recorded virtual time the OnError notification occurs.exception
(Error | Function): Recorded exception stored in the OnError notification or a predicate
Returns
(Recorded): Recorded OnError notification.
Example
var ex = new Error('woops');
var onError = Rx.ReactiveTest.onError;
var scheduler = new Rx.TestScheduler();
var xs = scheduler.createHotObservable(
onError(201, ex)
);
var res = scheduler.startWithCreate(function () {
return xs.map(function (x) { return x; });
});
// Write custom assertion
collectionAssert(res, [
// Using a predicate
onError(201, function (e) { return e.message === 'woops'; })
]);
Location
- rx.testing.js
Rx.ReactiveTest.onNext(ticks, value)
Factory method for an OnNext notification record at a given time with a given error.
Arguments
ticks
(Number): Recorded virtual time the OnNext notification occurs.value
(Any | Function): Recorded exception stored in the OnNext notification or a predicate
Returns
(Recorded): Recorded OnNext notification.
Example
var ex = new Error('woops');
var onNext = Rx.ReactiveTest.onNext;
var scheduler = new Rx.TestScheduler();
var xs = scheduler.createHotObservable(
onNext(201, 42)
);
var res = scheduler.startWithCreate(function () {
return xs.map(function (x) { return x; });
});
// Write custom assertion
collectionAssert(res, [
// Using a predicate
onNext(201, function (x) { return x === 42; })
]);
Location
- rx.testing.js
ReactiveTest Class Fields
Rx.ReactiveTest.created
Default virtual time used for creation of observable sequences in unit tests. This has a value of 100
.
Example
var scheduler = new Rx.TestScheduler();
var xs = scheduler.createHotObservable(
Rx.ReactiveTest.onNext(201, 42),
Rx.ReactiveTest.onNext(202, 56),
Rx.ReactiveTest.onCompleted(203)
);
var res = scheduler.startWithTiming(
function () { return xs.map(funxtion (x) { return x; })},
Rx.ReactiveTest.created,
Rx.ReactiveTest.subscribed,
Rx.ReactiveTest.disposed
);
Location
- rx.testing.js
Rx.ReactiveTest.disposed
Default virtual time used to dispose subscriptions in unit tests. This has a value of 1000
.
Example
var scheduler = new Rx.TestScheduler();
var xs = scheduler.createHotObservable(
Rx.ReactiveTest.onNext(201, 42),
Rx.ReactiveTest.onNext(202, 56),
Rx.ReactiveTest.onCompleted(203)
);
var res = scheduler.startWithTiming(
function () { return xs.map(funxtion (x) { return x; })},
Rx.ReactiveTest.created,
Rx.ReactiveTest.subscribed,
Rx.ReactiveTest.disposed
);
Location
- rx.testing.js
Rx.ReactiveTest.subscribed
Default virtual time used to subscribe to observable sequences in unit tests. This has a value of 200
.
Example
var scheduler = new Rx.TestScheduler();
var xs = scheduler.createHotObservable(
Rx.ReactiveTest.onNext(201, 42),
Rx.ReactiveTest.onNext(202, 56),
Rx.ReactiveTest.onCompleted(203)
);
var res = scheduler.startWithTiming(
function () { return xs.map(funxtion (x) { return x; })},
Rx.ReactiveTest.created,
Rx.ReactiveTest.subscribed,
Rx.ReactiveTest.disposed
);
Location
- rx.testing.js