-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(forEach): forEach can also take in an observer
- Loading branch information
1 parent
6f5ca75
commit 55c5b07
Showing
2 changed files
with
55 additions
and
16 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
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* Created by tushar on 09/09/17. | ||
*/ | ||
|
||
import * as assert from 'assert' | ||
import {forEach} from '../src/lib/ForEach' | ||
import {fromMarble} from '../src/testing/Marble' | ||
import {TestScheduler} from '../src/testing/TestScheduler' | ||
|
||
describe('forEach()', () => { | ||
it('should take a function as the default next', () => { | ||
const sh = TestScheduler.of() | ||
const $ = sh.Cold('-1234') | ||
const actual: number[] = [] | ||
forEach((i: number) => actual.push(i), $) | ||
const expected = ['1', '2', '3', '4'] | ||
sh.advanceBy(300) | ||
assert.deepEqual(actual, expected) | ||
}) | ||
|
||
it('should take an observer', () => { | ||
const sh = TestScheduler.of() | ||
const $ = sh.Cold('-1234|') | ||
const testObserver = sh.Observer() | ||
|
||
forEach(testObserver, $) | ||
sh.advanceBy(300) | ||
|
||
const actual = testObserver.results | ||
const expected = fromMarble('-1234|') | ||
|
||
assert.deepEqual(actual, expected) | ||
}) | ||
}) |