Skip to content

Commit

Permalink
Re-arranging tests
Browse files Browse the repository at this point in the history
  • Loading branch information
schottra committed Dec 18, 2019
1 parent 04619c4 commit fafaa8d
Showing 1 changed file with 76 additions and 77 deletions.
153 changes: 76 additions & 77 deletions src/components/Launch/LaunchWorkflowForm/test/inputConverters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,86 +42,87 @@ type PrimitiveTestParams = [InputType, any, Core.IPrimitive];
const validDateString = '2019-01-10T00:00:00.000Z'; // Dec 1, 2019

describe('inputToLiteral', () => {
describe('SimpleInput', () => {
const simpleTestCases: PrimitiveTestParams[] = [
[InputType.Boolean, true, { boolean: true }],
[InputType.Boolean, 'true', { boolean: true }],
[InputType.Boolean, 't', { boolean: true }],
[InputType.Boolean, '1', { boolean: true }],
[InputType.Boolean, 1, { boolean: true }],
[InputType.Boolean, false, { boolean: false }],
[InputType.Boolean, 'false', { boolean: false }],
[InputType.Boolean, 'f', { boolean: false }],
[InputType.Boolean, '0', { boolean: false }],
[InputType.Boolean, 0, { boolean: false }],
[
InputType.Datetime,
new Date('2019-01-10T00:00:00.000Z'),
{ datetime: dateToTimestamp(new Date(validDateString)) }
],
[
InputType.Datetime,
validDateString,
{ datetime: dateToTimestamp(new Date(validDateString)) }
],
[InputType.Duration, 0, { duration: millisecondsToDuration(0) }],
[
InputType.Duration,
10000,
{ duration: millisecondsToDuration(10000) }
],
[InputType.Float, 0, { floatValue: 0 }],
[InputType.Float, '0', { floatValue: 0 }],
[InputType.Float, -1.5, { floatValue: -1.5 }],
[InputType.Float, '-1.5', { floatValue: -1.5 }],
[InputType.Float, 1.5, { floatValue: 1.5 }],
[InputType.Float, '1.5', { floatValue: 1.5 }],
[InputType.Float, 1.25e10, { floatValue: 1.25e10 }],
[InputType.Float, '1.25e10', { floatValue: 1.25e10 }],
[InputType.Integer, 0, { integer: Long.fromNumber(0) }],
[
InputType.Integer,
Long.fromNumber(0),
{ integer: Long.fromNumber(0) }
],
[InputType.Integer, '0', { integer: Long.fromNumber(0) }],
[InputType.Integer, 1, { integer: Long.fromNumber(1) }],
[
InputType.Integer,
Long.fromNumber(1),
{ integer: Long.fromNumber(1) }
],
[InputType.Integer, '1', { integer: Long.fromNumber(1) }],
[InputType.Integer, -1, { integer: Long.fromNumber(-1) }],
[
InputType.Integer,
Long.fromNumber(-1),
{ integer: Long.fromNumber(-1) }
],
[InputType.Integer, '-1', { integer: Long.fromNumber(-1) }],
[
InputType.Integer,
Long.MAX_VALUE.toString(),
{ integer: Long.MAX_VALUE }
],
[InputType.Integer, Long.MAX_VALUE, { integer: Long.MAX_VALUE }],
[
InputType.Integer,
Long.MIN_VALUE.toString(),
{ integer: Long.MIN_VALUE }
],
[InputType.Integer, Long.MIN_VALUE, { integer: Long.MIN_VALUE }],
[InputType.String, '', { stringValue: '' }],
[InputType.String, 'abcdefg', { stringValue: 'abcdefg' }]
];

const simpleTestCases: PrimitiveTestParams[] = [
[InputType.Boolean, true, { boolean: true }],
[InputType.Boolean, 'true', { boolean: true }],
[InputType.Boolean, 't', { boolean: true }],
[InputType.Boolean, '1', { boolean: true }],
[InputType.Boolean, 1, { boolean: true }],
[InputType.Boolean, false, { boolean: false }],
[InputType.Boolean, 'false', { boolean: false }],
[InputType.Boolean, 'f', { boolean: false }],
[InputType.Boolean, '0', { boolean: false }],
[InputType.Boolean, 0, { boolean: false }],
[
InputType.Datetime,
new Date('2019-01-10T00:00:00.000Z'),
{ datetime: dateToTimestamp(new Date(validDateString)) }
],
[
InputType.Datetime,
validDateString,
{ datetime: dateToTimestamp(new Date(validDateString)) }
],
[InputType.Duration, 0, { duration: millisecondsToDuration(0) }],
[
InputType.Duration,
10000,
{ duration: millisecondsToDuration(10000) }
],
[InputType.Float, 0, { floatValue: 0 }],
[InputType.Float, '0', { floatValue: 0 }],
[InputType.Float, -1.5, { floatValue: -1.5 }],
[InputType.Float, '-1.5', { floatValue: -1.5 }],
[InputType.Float, 1.5, { floatValue: 1.5 }],
[InputType.Float, '1.5', { floatValue: 1.5 }],
[InputType.Float, 1.25e10, { floatValue: 1.25e10 }],
[InputType.Float, '1.25e10', { floatValue: 1.25e10 }],
[InputType.Integer, 0, { integer: Long.fromNumber(0) }],
[
InputType.Integer,
Long.fromNumber(0),
{ integer: Long.fromNumber(0) }
],
[InputType.Integer, '0', { integer: Long.fromNumber(0) }],
[InputType.Integer, 1, { integer: Long.fromNumber(1) }],
[
InputType.Integer,
Long.fromNumber(1),
{ integer: Long.fromNumber(1) }
],
[InputType.Integer, '1', { integer: Long.fromNumber(1) }],
[InputType.Integer, -1, { integer: Long.fromNumber(-1) }],
[
InputType.Integer,
Long.fromNumber(-1),
{ integer: Long.fromNumber(-1) }
],
[InputType.Integer, '-1', { integer: Long.fromNumber(-1) }],
[
InputType.Integer,
Long.MAX_VALUE.toString(),
{ integer: Long.MAX_VALUE }
],
[InputType.Integer, Long.MAX_VALUE, { integer: Long.MAX_VALUE }],
[
InputType.Integer,
Long.MIN_VALUE.toString(),
{ integer: Long.MIN_VALUE }
],
[InputType.Integer, Long.MIN_VALUE, { integer: Long.MIN_VALUE }],
[InputType.String, '', { stringValue: '' }],
[InputType.String, 'abcdefg', { stringValue: 'abcdefg' }]
];
describe('Primitives', () => {
simpleTestCases.map(([type, input, output]) =>
it(`Should correctly convert ${type}: ${input} (${typeof input})`, () => {
const result = inputToLiteral(makeSimpleInput(type, input));
expect(result.scalar!.primitive).toEqual(output);
})
);
});

describe('Collections', () => {
simpleTestCases.map(([type, input, output]) => {
let value: any;
if (['boolean', 'number'].includes(typeof input)) {
Expand Down Expand Up @@ -151,8 +152,8 @@ describe('inputToLiteral', () => {
).toEqual(output);
});
});

// Unsupported / None types
});
describe('Unsupported Types', () => {
[
InputType.Binary,
InputType.Blob,
Expand All @@ -170,6 +171,4 @@ describe('inputToLiteral', () => {
})
);
});
describe('Collections', () => {});
describe('NestedCollections', () => {});
});

0 comments on commit fafaa8d

Please sign in to comment.