From 9d789c13e14ae9468dd6b81170c8aed17591512d Mon Sep 17 00:00:00 2001 From: David Lechner Date: Wed, 27 May 2020 12:48:59 -0500 Subject: [PATCH] add test for util.assert --- src/utils/index.test.ts | 10 +++++++++- src/utils/index.ts | 1 - 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/utils/index.test.ts b/src/utils/index.test.ts index 57a41101..203ceede 100644 --- a/src/utils/index.test.ts +++ b/src/utils/index.test.ts @@ -1,7 +1,15 @@ // SPDX-License-Identifier: MIT // Copyright (c) 2020 The Pybricks Authors -import { hex } from '.'; +import { assert, hex } from '.'; + +test('assert', () => { + const assertTrue = jest.fn(() => assert(true, 'should not throw')); + assertTrue(); + expect(assertTrue).toHaveReturned(); + + expect(() => assert(false, 'should throw')).toThrow(); +}); test('hex', () => { expect(hex(0, 2)).toBe('0x00'); diff --git a/src/utils/index.ts b/src/utils/index.ts index 7c336e75..ea7af95f 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -8,7 +8,6 @@ * @param message Informational message for debugging */ export function assert(condition: boolean, message: string): void { - /* istanbul ignore next */ if (!condition) { throw Error(message); }