From 26575e4ae0a3f049ddf2d99162e45cb095562664 Mon Sep 17 00:00:00 2001 From: Oprysk Date: Tue, 23 Nov 2021 17:45:05 +0200 Subject: [PATCH] add more tests --- src/utils/__tests__/openapi.test.ts | 8 ++++++++ src/utils/openapi.ts | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/utils/__tests__/openapi.test.ts b/src/utils/__tests__/openapi.test.ts index 059220d0..33d45c9c 100644 --- a/src/utils/__tests__/openapi.test.ts +++ b/src/utils/__tests__/openapi.test.ts @@ -466,6 +466,14 @@ describe('Utils', () => { ); }); + it('should return correct min value', () => { + expect(humanizeNumberRange({ minimum: 5, exclusiveMinimum: 10 })).toEqual('> 5'); + }); + + it('should return correct max value', () => { + expect(humanizeNumberRange({ maximum: 10, exclusiveMaximum: 15 })).toEqual('< 15'); + }); + it('should return undefined', () => { expect(humanizeNumberRange({})).toEqual(undefined); }); diff --git a/src/utils/openapi.ts b/src/utils/openapi.ts index f69fb2ad..81923bb5 100644 --- a/src/utils/openapi.ts +++ b/src/utils/openapi.ts @@ -428,7 +428,7 @@ export function humanizeNumberRange(schema: OpenAPISchema): string | undefined { : schema.minimum; const maximum = typeof schema.exclusiveMaximum === 'number' - ? Math.min(schema.exclusiveMaximum, schema.maximum ?? Infinity) + ? Math.max(schema.exclusiveMaximum, schema.maximum ?? Infinity) : schema.maximum; const exclusiveMinimum = typeof schema.exclusiveMinimum === 'number' ? true : schema.exclusiveMinimum;