mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
tests(ui): coverage for validateConnectionTypes
This commit is contained in:
parent
059d5a682c
commit
8074a802d6
@ -175,7 +175,7 @@ describe(validateConnectionTypes.name, () => {
|
|||||||
it.each(typePairs)('should accept Collection $t1 to Collection $t2', ({ t1, t2 }: TypePair) => {
|
it.each(typePairs)('should accept Collection $t1 to Collection $t2', ({ t1, t2 }: TypePair) => {
|
||||||
const r = validateConnectionTypes(
|
const r = validateConnectionTypes(
|
||||||
{ name: t1, isCollection: true, isCollectionOrScalar: false },
|
{ name: t1, isCollection: true, isCollectionOrScalar: false },
|
||||||
{ name: t2, isCollection: false, isCollectionOrScalar: false }
|
{ name: t2, isCollection: true, isCollectionOrScalar: false }
|
||||||
);
|
);
|
||||||
expect(r).toBe(true);
|
expect(r).toBe(true);
|
||||||
});
|
});
|
||||||
|
@ -40,18 +40,25 @@ export const validateConnectionTypes = (sourceType: FieldType, targetType: Field
|
|||||||
|
|
||||||
const isCollectionToGenericCollection = targetType.name === 'CollectionField' && sourceType.isCollection;
|
const isCollectionToGenericCollection = targetType.name === 'CollectionField' && sourceType.isCollection;
|
||||||
|
|
||||||
const areBothTypesSingle =
|
const isSourceScalar = !sourceType.isCollection && !sourceType.isCollectionOrScalar;
|
||||||
!sourceType.isCollection &&
|
const isTargetScalar = !targetType.isCollection && !targetType.isCollectionOrScalar;
|
||||||
!sourceType.isCollectionOrScalar &&
|
const isScalarToScalar = isSourceScalar && isTargetScalar;
|
||||||
!targetType.isCollection &&
|
const isScalarToCollectionOrScalar = isSourceScalar && targetType.isCollectionOrScalar;
|
||||||
!targetType.isCollectionOrScalar;
|
const isCollectionToCollection = sourceType.isCollection && targetType.isCollection;
|
||||||
|
const isCollectionToCollectionOrScalar = sourceType.isCollection && targetType.isCollectionOrScalar;
|
||||||
|
const isCollectionOrScalarToCollectionOrScalar = sourceType.isCollectionOrScalar && targetType.isCollectionOrScalar;
|
||||||
|
const isPluralityMatch =
|
||||||
|
isScalarToScalar ||
|
||||||
|
isCollectionToCollection ||
|
||||||
|
isCollectionToCollectionOrScalar ||
|
||||||
|
isCollectionOrScalarToCollectionOrScalar ||
|
||||||
|
isScalarToCollectionOrScalar;
|
||||||
|
|
||||||
const isIntToFloat = areBothTypesSingle && sourceType.name === 'IntegerField' && targetType.name === 'FloatField';
|
const isIntToFloat = sourceType.name === 'IntegerField' && targetType.name === 'FloatField';
|
||||||
|
const isIntToString = sourceType.name === 'IntegerField' && targetType.name === 'StringField';
|
||||||
|
const isFloatToString = sourceType.name === 'FloatField' && targetType.name === 'StringField';
|
||||||
|
|
||||||
const isIntOrFloatToString =
|
const isSubTypeMatch = isPluralityMatch && (isIntToFloat || isIntToString || isFloatToString);
|
||||||
areBothTypesSingle &&
|
|
||||||
(sourceType.name === 'IntegerField' || sourceType.name === 'FloatField') &&
|
|
||||||
targetType.name === 'StringField';
|
|
||||||
|
|
||||||
const isTargetAnyType = targetType.name === 'AnyField';
|
const isTargetAnyType = targetType.name === 'AnyField';
|
||||||
|
|
||||||
@ -62,8 +69,7 @@ export const validateConnectionTypes = (sourceType: FieldType, targetType: Field
|
|||||||
isAnythingToCollectionOrScalarOfSameBaseType ||
|
isAnythingToCollectionOrScalarOfSameBaseType ||
|
||||||
isGenericCollectionToAnyCollectionOrCollectionOrScalar ||
|
isGenericCollectionToAnyCollectionOrCollectionOrScalar ||
|
||||||
isCollectionToGenericCollection ||
|
isCollectionToGenericCollection ||
|
||||||
isIntToFloat ||
|
isSubTypeMatch ||
|
||||||
isIntOrFloatToString ||
|
|
||||||
isTargetAnyType
|
isTargetAnyType
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user