From 498d6db794198cf13d5f6740f5cec2bde3a646d4 Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Tue, 26 Sep 2023 15:26:08 -0230 Subject: [PATCH] Add tests for the assertIsError function --- packages/name-controller/src/utils.test.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/name-controller/src/utils.test.ts b/packages/name-controller/src/utils.test.ts index b5d0ef2308..556af3bb84 100644 --- a/packages/name-controller/src/utils.test.ts +++ b/packages/name-controller/src/utils.test.ts @@ -1,4 +1,4 @@ -import { graphQL } from './util'; +import { assertIsError, graphQL } from './util'; describe('Utils', () => { describe('graphQL', () => { @@ -51,4 +51,16 @@ describe('Utils', () => { ); }); }); + + describe('assertIsError', () => { + it('does not throw if given an error', () => { + expect(() => assertIsError(new Error('test'))).not.toThrow(); + }); + + it('throws if passed something that is not an error', () => { + expect(() => assertIsError('test')).toThrow( + `Invalid error of type 'string'`, + ); + }); + }); });