-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(test): use test marbles for combinelatest observable spec
- Loading branch information
Showing
1 changed file
with
11 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,17 @@ | ||
/* globals describe, it, expect */ | ||
/* globals describe, it, expect, expectObservable, hot */ | ||
var Rx = require('../../dist/cjs/Rx'); | ||
var Observable = Rx.Observable; | ||
|
||
describe('Observable.combineLatest', function () { | ||
it('should combineLatest the provided observables', function (done) { | ||
var expected = ['00', '01', '11', '12', '22', '23']; | ||
var i = 0; | ||
|
||
Observable.combineLatest( | ||
Observable.interval(50).take(3), | ||
Observable.interval(45).take(4), | ||
function (a, b) { | ||
it('should combineLatest the provided observables', function () { | ||
var firstSource = hot('----a----b----c----|'); | ||
var secondSource = hot('--d--e--f--g--|'); | ||
var expected = '----uv--wx-y--z----|'; | ||
|
||
var combined = Observable.combineLatest(firstSource, secondSource, function (a, b) { | ||
return '' + a + b; | ||
} | ||
) | ||
.subscribe(function (x) { | ||
expect(x).toBe(expected[i++]) | ||
}, null, | ||
function () { | ||
done(); | ||
}); | ||
}, 300); | ||
}) | ||
|
||
expectObservable(combined).toBe(expected, {u: 'ad', v: 'ae', w: 'af', x: 'bf', y: 'bg', z: 'cg'}); | ||
}); | ||
}); |