From 8e26a3b41769510daf10cae75f52dd04288f099c Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Sat, 12 Dec 2020 10:39:19 +0100 Subject: [PATCH] chore: test getCodeFromName throw License: MIT Signed-off-by: Henrique Dias --- test/multicodec.spec.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/test/multicodec.spec.js b/test/multicodec.spec.js index 1878865..e966b20 100644 --- a/test/multicodec.spec.js +++ b/test/multicodec.spec.js @@ -89,7 +89,7 @@ describe('multicodec', () => { expect(multicodec.getNameFromCode(0x01a5)).to.eql('p2p') }) - it('throws error on unknown codec name when getting the code', () => { + it('throws error on unknown codec name when getting the varint from name', () => { expect(() => { // @ts-expect-error multicodec.getVarintFromName('this-codec-doesnt-exist') @@ -98,7 +98,16 @@ describe('multicodec', () => { ) }) - it('throws error on unknown codec name when getting the codec', () => { + it('throws error on unknown codec name when getting the code from name', () => { + expect(() => { + // @ts-expect-error + multicodec.getCodeFromName('this-codec-doesnt-exist') + }).to.throw( + 'Codec "this-codec-doesnt-exist" not found' + ) + }) + + it('throws error on unknown codec name when getting the name from the code', () => { const code = uint8ArrayFromString('ffee', 'base16') const buf = uint8ArrayFromString('hey')