-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: tests for concat and collect and missing exported type
- Loading branch information
Showing
8 changed files
with
47 additions
and
14 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,16 +1,17 @@ | ||
import { assert } from 'chai' | ||
import { collect } from '../lib/collect' | ||
import { fromIterable } from '../lib/from-iterable' | ||
import { collect, fromIterable } from './' | ||
|
||
function promiseImmediate (data?) { | ||
return new Promise(resolve => setImmediate(() => resolve(data))) | ||
async function* asyncIterable (arr) { | ||
for (const val of arr) { | ||
yield val | ||
} | ||
} | ||
|
||
describe('collect', () => { | ||
it('collects async data', async () => { | ||
assert.deepEqual(await collect(fromIterable([1, 2, 3, 4])), [1, 2, 3, 4]) | ||
it('collects async iterator data', async () => { | ||
assert.deepEqual(await collect(asyncIterable([1, 2, 3, 4])), [1, 2, 3, 4]) | ||
}) | ||
it('collects sync data', async () => { | ||
it('collects sync iterable data', async () => { | ||
assert.deepEqual(await collect([1, 2, 3, 4]), [1, 2, 3, 4]) | ||
}) | ||
}) |
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,18 @@ | ||
import { assert } from 'chai' | ||
import { collect, concat, fromIterable } from './' | ||
|
||
describe('concat', () => { | ||
it('concatenates multiple async iterators', async () => { | ||
async function* one () { yield 1 } | ||
async function* two () { yield 2 } | ||
assert.deepEqual(await collect(concat(one(), two())), [1, 2]) | ||
}) | ||
it('concatenates multiple sync iterators', async () => { | ||
function* one () { yield 1 } | ||
function* two () { yield 2 } | ||
assert.deepEqual(await collect(concat(one(), two())), [1, 2]) | ||
}) | ||
it('concatenates sync iterables', async () => { | ||
assert.deepEqual(await collect(concat([1], [2], [3], [4])), [1, 2, 3, 4]) | ||
}) | ||
}) |
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
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
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 @@ | ||
export type Iterableish<T> = Iterable<T>|Iterator<T>|AsyncIterable<T>|AsyncIterator<T> |