mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 01:23:52 +00:00
add test for util.assert
This commit is contained in:
committed by
David Lechner
parent
59c14a3ad7
commit
9d789c13e1
@@ -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');
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user