Skip to content

Commit

Permalink
document exception behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
crccheck committed Feb 20, 2017
1 parent 7d8d219 commit 9c8a599
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,26 @@ describe('main', () => {
assert.equal(reader._readableState.buffer.length, 1)
assert.deepEqual(reader._readableState.buffer.head.data, {foo: 'bar'})
})

it('parser exceptions are passed through', () => {
const record = {
Data: '{"foo":"bar"}',
SequenceNumber: 'seq-1',
}
const getNextIterator = sinon.stub().returns(undefined)
client.getRecords = (params, cb) =>
cb(undefined, {Records: [record], NextShardIterator: getNextIterator()})
const reader = new main.KinesisStreamReader(client, 'stream name', {
parser: () => { throw new Error('lolwut') },
})

try {
reader.readShard('shard-iterator-6')
assert(false, 'reader should have thrown')
} catch (err) {
assert.equal(err.message, 'lolwut')
}
})
})
})

Expand Down

0 comments on commit 9c8a599

Please sign in to comment.