From 139c8bc4edc1eaaec80ebd58ca3efdda63935458 Mon Sep 17 00:00:00 2001 From: Ludovic Dussart Date: Thu, 14 Oct 2021 11:07:18 +0200 Subject: [PATCH] fixup: reduce code duplication --- tests/to-json-schema.test.js | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/tests/to-json-schema.test.js b/tests/to-json-schema.test.js index 35b6801e..f5a202bf 100644 --- a/tests/to-json-schema.test.js +++ b/tests/to-json-schema.test.js @@ -218,23 +218,19 @@ describe('additionalAttributesMapping()', function () { expect(result).toMatchObject({type: 'number', format: 'double', exclusiveMinimum: 0, exclusiveMaximum: 10}); }); - it('support minimum and maximum for int', async function () { - const result = await avroToJsonSchema({type: 'int', minimum: 0, maximum: 10}); + it('support minimum and maximum for long and int', async function () { + let result = await avroToJsonSchema({type: 'long', minimum: 0, maximum: 10}); expect(result).toEqual({type: 'integer', minimum: 0, maximum: 10}); - }); - - it('support exclusiveMinimum and exclusiveMaximum for int', async function () { - const result = await avroToJsonSchema({type: 'int', exclusiveMinimum: 0, exclusiveMaximum: 10}); - expect(result).toMatchObject({type: 'integer', exclusiveMinimum: 0, exclusiveMaximum: 10}); - }); - it('support minimum and maximum for long', async function () { - const result = await avroToJsonSchema({type: 'long', minimum: 0, maximum: 10}); + result = await avroToJsonSchema({type: 'int', minimum: 0, maximum: 10}); expect(result).toEqual({type: 'integer', minimum: 0, maximum: 10}); }); - it('support exclusiveMinimum and exclusiveMaximum for long', async function () { - const result = await avroToJsonSchema({type: 'long', exclusiveMinimum: 0, exclusiveMaximum: 10}); + it('long and int type support exclusiveMinimum and exclusiveMaximum', async function () { + let result = await avroToJsonSchema({type: 'long', exclusiveMinimum: 0, exclusiveMaximum: 10}); + expect(result).toMatchObject({type: 'integer', exclusiveMinimum: 0, exclusiveMaximum: 10}); + + result = await avroToJsonSchema({type: 'int', exclusiveMinimum: 0, exclusiveMaximum: 10}); expect(result).toMatchObject({type: 'integer', exclusiveMinimum: 0, exclusiveMaximum: 10}); });