From ead2f0316ba36a947d9a75bccfa7477b57cc5540 Mon Sep 17 00:00:00 2001 From: nedsalk Date: Fri, 4 Oct 2024 18:50:37 +0200 Subject: [PATCH] add tests --- .../src/matchers/sway-type-matchers.test.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/packages/abi/src/matchers/sway-type-matchers.test.ts b/packages/abi/src/matchers/sway-type-matchers.test.ts index a25fda0ef6b..03dc81f169c 100644 --- a/packages/abi/src/matchers/sway-type-matchers.test.ts +++ b/packages/abi/src/matchers/sway-type-matchers.test.ts @@ -245,4 +245,23 @@ describe('sway type matchers', () => { expect(matcher({ swayType })).toEqual(`${key}-matched`); verifyOtherMatchersDontMatch(key, swayType); }); + + test('str', () => { + const key = 'str'; + const swayType = 'str'; + + expect(matcher({ swayType })).toEqual(`${key}-matched`); + verifyOtherMatchersDontMatch(key, swayType); + }); + + test('matcher without mapping for valid sway type throws', () => { + const swayType = 'str'; + + // @ts-expect-error intentionally missing key for valid swayType + const matcherWithoutMappings = createMatcher({}); + + expect(() => matcherWithoutMappings({ swayType })).toThrow( + `Matcher not found for sway type ${swayType}.` + ); + }); });