mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 08:02:28 +00:00
test(mobile): narrow the incompatible-reply error by instanceof, not by cast
The two new tests in f741b2ea82 read the error through `as` casts, which the
changed-code casting gate rejects. An `instanceof` guard narrows the same value
and checks the class at the same time.
Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
This commit is contained in:
@@ -330,12 +330,13 @@ describe('an incompatible reply', () => {
|
||||
{}
|
||||
).catch((thrown: unknown) => thrown)
|
||||
|
||||
expect((caught as Error).message).toBe(
|
||||
'The host sent a reply this app could not read (worktree.ps)'
|
||||
)
|
||||
expect((caught as Error).message).not.toContain('incompatible_reply')
|
||||
expect((caught as RpcIncompatibleReplyError).code).toBe(RPC_INCOMPATIBLE_REPLY_CODE)
|
||||
expect((caught as Error).name).toBe('RpcIncompatibleReplyError')
|
||||
if (!(caught instanceof RpcIncompatibleReplyError)) {
|
||||
throw new Error('expected an incompatible-reply error')
|
||||
}
|
||||
expect(caught.message).toBe('The host sent a reply this app could not read (worktree.ps)')
|
||||
expect(caught.message).not.toContain('incompatible_reply')
|
||||
expect(caught.code).toBe(RPC_INCOMPATIBLE_REPLY_CODE)
|
||||
expect(caught.name).toBe('RpcIncompatibleReplyError')
|
||||
})
|
||||
|
||||
// A second bundle copy of this module fails `instanceof`, so the name is the fallback.
|
||||
|
||||
Reference in New Issue
Block a user