Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nulltoken committed Jan 17, 2020
1 parent 12a4fae commit f8f05d0
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/functions/__tests__/formattedEnum.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,27 @@ describe('formattedEnum', () => {

describe('formats', () => {
const testCases: Array<[string, string, unknown[], unknown]> = [
['byte', 'string', ['SGVsbG8=', 'd29ybGQh'], 'Hello'],
// cf. https://github.com/amazing-gao/ajv-oai/blob/master/README.md#example
['int32', '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'],
['byte', 'string', ['SGVsbG8=', 'd29ybGQh'], 'Hello'],

// 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`, '', [], ''],
];

test.each(testCases)(
Expand All @@ -107,7 +126,7 @@ describe('formattedEnum', () => {

const results = runFormattedEnum(schema, defaultReportingThreshold);

expect(results[0].message).toContain(`"${invalid}"`);
expect(results[0].message).toContain(`: "${invalid}".`);
},
);
});
Expand Down

0 comments on commit f8f05d0

Please sign in to comment.