Skip to content
This repository was archived by the owner on May 20, 2024. It is now read-only.

Commit c73d649

Browse files
committed
test: stopping execution in the middle by returning a null or undefined result
1 parent 3a8dd8c commit c73d649

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,19 @@ test('AWSApiReadStream - initialize with existing token', async t => {
3434
t.is(stream._nextToken, 5)
3535
})
3636

37+
test('AWSApiReadStream - returning null or undefined will stop execution', async t => {
38+
const testapi = new TestAPI()
39+
const stream = AWSApiReadStream.from(nextToken => nextToken === 2 ? null : testapi.anAPICall(nextToken))
40+
41+
42+
const results = []
43+
for await (const { data, NextToken } of stream) {
44+
results.push(data)
45+
}
46+
t.deepEqual(results, [0, 1])
47+
})
48+
49+
3750
class TestAPI {
3851
constructor() {
3952
this._counter = 0

0 commit comments

Comments
 (0)