Skip to content

Commit

Permalink
fixup: reduce code duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
M3lkior committed Oct 18, 2021
1 parent 6d213f9 commit 139c8bc
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions tests/to-json-schema.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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});
});

Expand Down

0 comments on commit 139c8bc

Please sign in to comment.