https://github.com/whiteinge/rx-collectionassert
A port of the collectionassert function in the RxJS docs using Node's assert lib
https://github.com/whiteinge/rx-collectionassert
Last synced: 6 months ago
JSON representation
A port of the collectionassert function in the RxJS docs using Node's assert lib
- Host: GitHub
- URL: https://github.com/whiteinge/rx-collectionassert
- Owner: whiteinge
- Created: 2016-09-05T05:01:44.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-09-05T05:07:24.000Z (over 9 years ago)
- Last Synced: 2025-06-28T19:52:23.065Z (7 months ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# rx-collectionassert
A port of [assertEqual from the RxJS
docs](https://github.com/Reactive-Extensions/RxJS/blob/master/doc/gettingstarted/testing.md)
to work with Node's assert lib.
(I got tired of copy-and-pasting this between projects.)
## Usage
This works with any testing lib in Node; example below using
[tape](https://github.com/substack/tape).
```js
var test = require('tape');
var Rx = require('rx'),
ReactiveTest = Rx.ReactiveTest;
var collectionAssert = require('rx-collectionassert');
test('An RxJS test', function(assert) {
var scheduler = new Rx.TestScheduler();
var source = scheduler.createHotObservable(
ReactiveTest.onNext(250, 'foo'),
ReactiveTest.onNext(260, 'bar'),
ReactiveTest.onCompleted(270));
var results = scheduler.startScheduler(function() {
return source.map(x => x);
}, {created: 100, subscribed: 200, disposed: 500});
collectionAssert.assertEqual(results.messages, [
ReactiveTest.onNext(250, 'foo'),
ReactiveTest.onNext(260, 'bar'),
ReactiveTest.onCompleted(270),
]);
assert.end();
});
```