test: walk along dependency chains

This commit is contained in:
Karl-Philipp Wulfert
2019-06-05 16:14:18 +02:00
parent ff1f554e0b
commit 46194b177b

View File

@@ -193,7 +193,7 @@ export class SchemaSpec {
continue; continue;
} }
const type = property.type!; let type = property.type!;
if (isIntrinsicType(type)) { if (isIntrinsicType(type)) {
continue; continue;
@@ -212,10 +212,24 @@ export class SchemaSpec {
fail(`'${thingName}'#'${property.name}' element type '${elementType.type}' is not handled by this test!`); fail(`'${thingName}'#'${property.name}' element type '${elementType.type}' is not handled by this test!`);
} }
} else if (isReferenceType(type)) { } else if (isReferenceType(type)) {
expect(SchemaSpec.thingNames).not.to.contain( do {
type.name, expect(SchemaSpec.thingNames).not.to.contain(
`Property '${property.name}' on type '${thingName}' has element type '${type.name}'.`, type.name,
); `Property '${property.name}' on type '${thingName}' has element type '${type.name}'.`,
);
const referencedObject = SchemaSpec.objects[type.name];
if (typeof referencedObject !== 'undefined') {
const referencedType = referencedObject.type;
if (typeof referencedType !== 'undefined') {
type = referencedType;
} else {
break;
}
} else {
break;
}
} while (isReferenceType(type));
} else if (isUnionType(type)) { } else if (isUnionType(type)) {
for (const nestedType of type.types) { for (const nestedType of type.types) {
if (isIntrinsicType(nestedType) || isStringLiteralType(nestedType)) { if (isIntrinsicType(nestedType) || isStringLiteralType(nestedType)) {