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); }