From 025f28cd6e56bad047899a7900b1b23f562a83ac Mon Sep 17 00:00:00 2001 From: nulltoken Date: Fri, 17 Jan 2020 22:28:43 +0100 Subject: [PATCH] More tests --- src/functions/__tests__/typedEnum.test.ts | 35 ++++++++----------- ...oas3.scenario => typed-enum.oas3.scenario} | 3 +- 2 files changed, 16 insertions(+), 22 deletions(-) rename test-harness/scenarios/{formatted-enum.oas3.scenario => typed-enum.oas3.scenario} (90%) diff --git a/src/functions/__tests__/typedEnum.test.ts b/src/functions/__tests__/typedEnum.test.ts index ff41d6494..a8f3af086 100644 --- a/src/functions/__tests__/typedEnum.test.ts +++ b/src/functions/__tests__/typedEnum.test.ts @@ -73,28 +73,23 @@ describe('typedEnum', () => { }); describe('types', () => { + /* + + string (this includes dates and files) + number + integer + boolean + array + object + + */ const testCases: Array<[string, unknown[], unknown]> = [ - // cf. https://github.com/amazing-gao/ajv-oai/blob/master/README.md#example - ['integer', [-2147483648, 17], 'Hello'], - // [`int64`, 'integer', [9223372036854775807, -127], 'Hello'], - // [`float`, 'number', [1.12, Math.pow(2, 128)], 'Hello'], - // [`double`, 'number', [-3.151, Math.pow(2, 1024) * -1], 'Hello'], ['string', ['Hello', 'world!'], 12], - - // cf. https://github.com/epoberezkin/ajv/blob/master/README.md#formats - // [`time`, '', [], ''], - // [`date-time`, '', [], ''], - // [`uri`, '', [], ''], - // [`uri-reference`, '', [], ''], - // [`uri-template`, '', [], ''], - // [`email`, '', [], ''], - // [`hostname`, '', [], ''], - // [`ipv4`, '', [], ''], - // [`ipv6`, '', [], ''], - // [`regex`, '', [], ''], - // [`uuid`, '', [], ''], - // [`json-pointer`, '', [], ''], - // [`relative-json-pointer`, '', [], ''], + ['number', [-2147483648, 17.13], 'Hello'], + ['integer', [-2147483648, 17], 12.3], + ['boolean', [true, false], 1], + // array ? + // object ? ]; test.each(testCases)( diff --git a/test-harness/scenarios/formatted-enum.oas3.scenario b/test-harness/scenarios/typed-enum.oas3.scenario similarity index 90% rename from test-harness/scenarios/formatted-enum.oas3.scenario rename to test-harness/scenarios/typed-enum.oas3.scenario index 051c2180c..e5b2598b0 100644 --- a/test-harness/scenarios/formatted-enum.oas3.scenario +++ b/test-harness/scenarios/typed-enum.oas3.scenario @@ -22,13 +22,12 @@ components: - 12254 - You certainly wonder - Why I gathered you all today... - format: int64 ====command==== {bin} lint {document} --ruleset {asset:ruleset} ====stdout==== OpenAPI 3.x detected {document} - 7:12 error typed-enum Some enum values do not respect the specified format "int64": "Tap, tap, tap...", "Is thing thing on?", "You certainly wonder"... + 7:12 error typed-enum Some enum values do not respect the specified type "integer": "Tap, tap, tap...", "Is thing thing on?", "You certainly wonder"... ✖ 1 problem (1 error, 0 warnings, 0 infos, 0 hints)