Additional tests (w/ lazy) (#1174)

This commit is contained in:
Jaco
2021-11-12 08:44:00 +02:00
committed by GitHub
parent 9b30b4b09e
commit 31d55b218a
8 changed files with 172 additions and 3 deletions
+17 -1
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2021 @polkadot/util authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { assert } from '.';
import { assert, assertReturn } from '.';
describe('assert', (): void => {
it('should not throw an error when test is true', (): void => {
@@ -20,3 +20,19 @@ describe('assert', (): void => {
).toThrow(/message from function/);
});
});
describe('assertReturn', (): void => {
it('should not throw an error when result is true', (): void => {
expect(assertReturn(true, 'nothing should be thrown')).toEqual(true);
});
it('should not throw an error when result is false', (): void => {
expect(assertReturn(false, 'nothing should be thrown')).toEqual(false);
});
it('should throw an error when result is undefined', (): void => {
expect(
() => assertReturn(undefined, 'something thrown')
).toThrow(/something thrown/);
});
});