Skip to content

Commit

Permalink
Add a test for async iterables (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky authored Mar 13, 2024
1 parent 7a76e3e commit c507089
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/contents.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,24 @@ test('works with async iterable', async t => {
t.is(result, 'ab');
});

const finallyGenerator = async function * (state) {
try {
yield {};
} catch (error) {
state.error = true;
throw error;
} finally {
state.finally = true;
}
};

test('async iterable .return() is called on error, but not .throw()', async t => {
const state = {error: false, finally: false};
await t.throwsAsync(getStream(finallyGenerator(state)));
t.false(state.error);
t.true(state.finally);
});

test('get stream with mixed chunk types', async t => {
const fixtures = [fixtureString, fixtureBuffer, fixtureArrayBuffer, fixtureTypedArray, fixtureUint16Array, fixtureDataView];
const result = await setupString(fixtures);
Expand Down

0 comments on commit c507089

Please sign in to comment.