Skip to content

Commit

Permalink
test: add value test cases for schema
Browse files Browse the repository at this point in the history
  • Loading branch information
schottra committed Oct 22, 2020
1 parent 11e791b commit 568b984
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@ describe('validateInput', () => {
generateValidityTests(inputTypes.integer, validityTestCases.integer);
});

describe('schema', () => {
generateValidityTests(inputTypes.schema, validityTestCases.schema);
});

describe('string', () => {
generateValidityTests(inputTypes.string, validityTestCases.string);
});
Expand Down
29 changes: 29 additions & 0 deletions src/components/Launch/LaunchForm/inputHelpers/test/testCases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ export const validityTestCases = {
Long.MIN_VALUE
]
},
// schema is just a specialized string input, so it has the same validity cases as string
schema: { invalid: [123, true, new Date(), {}], valid: ['', 'abcdefg'] },
string: { invalid: [123, true, new Date(), {}], valid: ['', 'abcdefg'] }
};

Expand Down Expand Up @@ -296,6 +298,27 @@ export const literalTestCases: LiteralTestParams[] = [
Long.MIN_VALUE,
primitiveLiteral({ integer: Long.MIN_VALUE })
],
[
inputTypes.schema,
'',
{
scalar: {
schema: { type: inputTypes.schema.literalType.schema, uri: '' }
}
}
],
[
inputTypes.schema,
's3://someUri',
{
scalar: {
schema: {
type: inputTypes.schema.literalType.schema,
uri: 's3://someUri'
}
}
}
],
[inputTypes.string, '', primitiveLiteral({ stringValue: '' })],
[
inputTypes.string,
Expand Down Expand Up @@ -474,6 +497,12 @@ export const literalToInputTestCases: InputToLiteralTestParams[] = [
primitiveLiteral({ integer: Long.MIN_VALUE }),
Long.MIN_VALUE.toString()
],
[inputTypes.schema, { scalar: { schema: { uri: '' } } }, ''],
[
inputTypes.schema,
{ scalar: { schema: { uri: 's3://someUri' } } },
's3://someUri'
],
[inputTypes.string, primitiveLiteral({ stringValue: '' }), ''],
[
inputTypes.string,
Expand Down

0 comments on commit 568b984

Please sign in to comment.