Skip to content

Commit

Permalink
Fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian-Schopp committed Nov 2, 2023
1 parent ec40c03 commit 3913bfd
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test/peer/peer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,44 @@ describe('Testing Peer', () => {
done()
})
})
it('should fail call with thrown string', (done) => {
const s = new Method('foo')
s.on('call', () => {
throw 'test'
})
peer.add(s).then(() => {
const par = { path: 'foo', value: 5 }
cbs['call'](undefined, 'fooId', par)

expect(jsonRpc.respond).toBeCalledWith(
'fooId',
new InvalidParamError('InvalidParam', 'Failed to call method'),
false
)
done()
})
})
it('should fail call with thrown object', (done) => {
const s = new Method('foo')
s.on('call', () => {
throw { test: 4 }
})
peer.add(s).then(() => {
const par = { path: 'foo', value: 5 }
cbs['call'](undefined, 'fooId', par)

expect(jsonRpc.respond).toBeCalledWith(
'fooId',
new InvalidParamError(
'InvalidParam',
'Failed to call method',
'details'
),
false
)
done()
})
})
it('should fail set with error', (done) => {
const s = new State<ValueType>('foo', 5)
s.on('set', () => {
Expand Down

0 comments on commit 3913bfd

Please sign in to comment.