From 9eebd42887ff9a6555be526992d88f273830cdc9 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Mon, 28 Sep 2026 04:07:02 +0200 Subject: [PATCH] Test that bound() takes a bind type as a string and names the fix for a wrong one --- test/session.test.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/test/session.test.ts b/test/session.test.ts index 1c8a5c8..1f31f0b 100644 --- a/test/session.test.ts +++ b/test/session.test.ts @@ -463,12 +463,11 @@ describe('bind', () => { assert.deepEqual(session.bound('transmitter', undefined), {}); assert.equal(session.peerInterfaceVersion, 0x00, 'no declared version is pre-3.4'); - // The mistakes an untyped caller makes: the TLV object for its value, a version past int8, a typo. - for (const [bindType, declared] of [['receiver', { tagValue: 0x34 }], ['receiver', 0x100], ['receiver', 3.4], ['tx', 0x34]]) { - const refused: unknown = Reflect.apply(Reflect.get(session, 'bound'), session, [bindType, declared]); - - assert.ok(refused && typeof refused === 'object' && 'err' in refused && refused.err instanceof Error); - } + // The likeliest mistakes: the TLV object for its value, a version past int8, the command's name. + assert.match(session.bound('receiver', { tagValue: 0x34 }).err?.message ?? '', /tagValue, or undefined .* got object$/); + assert.ok(session.bound('receiver', 0x100).err); + assert.ok(session.bound('receiver', 3.4).err); + assert.match(session.bound('bind_receiver', 0x34).err?.message ?? '', /without "bind_", got "bind_receiver"$/); assert.equal(session.boundAs, 'transmitter', 'a refused bind leaves the recorded one alone'); assert.equal(session.peerInterfaceVersion, 0x00);