From: Jérôme Benoit Date: Sun, 8 Oct 2023 13:58:58 +0000 (+0200) Subject: test: toThrowError() -> toThrow() X-Git-Tag: v1.2.24~109 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=68f56fdffd6d0d8c3e80ebf1657c81216d4f072f;p=e-mobility-charging-stations-simulator.git test: toThrowError() -> toThrow() Signed-off-by: Jérôme Benoit --- diff --git a/tests/utils/CircularArray.test.ts b/tests/utils/CircularArray.test.ts index 90404f87..01cff444 100644 --- a/tests/utils/CircularArray.test.ts +++ b/tests/utils/CircularArray.test.ts @@ -30,13 +30,13 @@ await describe('CircularArray test suite', async () => { }); await it('Verify that circular array size is valid at instance creation', () => { - expect(() => new CircularArray(0.25)).toThrowError( + expect(() => new CircularArray(0.25)).toThrow( new TypeError('Invalid circular array size: 0.25 is not a safe integer'), ); - expect(() => new CircularArray(-1)).toThrowError( + expect(() => new CircularArray(-1)).toThrow( new RangeError('Invalid circular array size: -1 < 0'), ); - expect(() => new CircularArray(Number.MAX_SAFE_INTEGER + 1)).toThrowError( + expect(() => new CircularArray(Number.MAX_SAFE_INTEGER + 1)).toThrow( new TypeError( `Invalid circular array size: ${Number.MAX_SAFE_INTEGER + 1} is not a safe integer`, ), @@ -114,13 +114,13 @@ await describe('CircularArray test suite', async () => { }); await it('Verify that circular array resize works as intended', () => { - expect(() => new CircularArray().resize(0.25)).toThrowError( + expect(() => new CircularArray().resize(0.25)).toThrow( new TypeError('Invalid circular array size: 0.25 is not a safe integer'), ); - expect(() => new CircularArray().resize(-1)).toThrowError( + expect(() => new CircularArray().resize(-1)).toThrow( new RangeError('Invalid circular array size: -1 < 0'), ); - expect(() => new CircularArray().resize(Number.MAX_SAFE_INTEGER + 1)).toThrowError( + expect(() => new CircularArray().resize(Number.MAX_SAFE_INTEGER + 1)).toThrow( new TypeError( `Invalid circular array size: ${Number.MAX_SAFE_INTEGER + 1} is not a safe integer`, ), diff --git a/tests/utils/Utils.test.ts b/tests/utils/Utils.test.ts index 5592e68f..60170cf9 100644 --- a/tests/utils/Utils.test.ts +++ b/tests/utils/Utils.test.ts @@ -89,8 +89,8 @@ await describe('Utils test suite', async () => { await it('Verify convertToDate()', () => { expect(convertToDate(undefined)).toBe(undefined); - expect(() => convertToDate('')).toThrowError(new Error("Cannot convert to date: ''")); - expect(() => convertToDate('00:70:61')).toThrowError( + expect(() => convertToDate('')).toThrow(new Error("Cannot convert to date: ''")); + expect(() => convertToDate('00:70:61')).toThrow( new Error("Cannot convert to date: '00:70:61'"), ); expect(convertToDate(0)).toStrictEqual(new Date('1970-01-01T00:00:00.000Z')); @@ -179,13 +179,13 @@ await describe('Utils test suite', async () => { randomInteger = getRandomInteger(0, -Constants.MAX_RANDOM_INTEGER); expect(randomInteger).toBeGreaterThanOrEqual(-Constants.MAX_RANDOM_INTEGER); expect(randomInteger).toBeLessThanOrEqual(0); - expect(() => getRandomInteger(0, 1)).toThrowError( + expect(() => getRandomInteger(0, 1)).toThrow( 'The value of "max" is out of range. It must be greater than the value of "min" (1). Received 1', ); - expect(() => getRandomInteger(-1)).toThrowError( + expect(() => getRandomInteger(-1)).toThrow( 'The value of "max" is out of range. It must be greater than the value of "min" (0). Received 0', ); - expect(() => getRandomInteger(Constants.MAX_RANDOM_INTEGER + 1)).toThrowError( + expect(() => getRandomInteger(Constants.MAX_RANDOM_INTEGER + 1)).toThrow( `The value of "max" is out of range. It must be <= ${ Constants.MAX_RANDOM_INTEGER + 1 }. Received 281_474_976_710_656`, @@ -221,8 +221,8 @@ await describe('Utils test suite', async () => { expect(randomFloat).toBeGreaterThanOrEqual(0); expect(randomFloat).toBeLessThanOrEqual(Number.MAX_VALUE); expect(randomFloat).not.toEqual(getRandomFloat()); - expect(() => getRandomFloat(0, 1)).toThrowError(new RangeError('Invalid interval')); - expect(() => getRandomFloat(Number.MAX_VALUE, -Number.MAX_VALUE)).toThrowError( + expect(() => getRandomFloat(0, 1)).toThrow(new RangeError('Invalid interval')); + expect(() => getRandomFloat(Number.MAX_VALUE, -Number.MAX_VALUE)).toThrow( new RangeError('Invalid interval'), ); randomFloat = getRandomFloat(0, -Number.MAX_VALUE);