add more tests

This commit is contained in:
Oprysk 2021-11-23 17:45:05 +02:00
parent 3417c956d7
commit 26575e4ae0
2 changed files with 9 additions and 1 deletions

View File

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

View File

@ -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;