From 46194b177be7445b63172ae1d010aff357dddd4d Mon Sep 17 00:00:00 2001 From: Karl-Philipp Wulfert Date: Wed, 5 Jun 2019 16:14:18 +0200 Subject: [PATCH] test: walk along dependency chains --- test/Schema.spec.ts | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/test/Schema.spec.ts b/test/Schema.spec.ts index 48a5e9d8..77dc3ab4 100644 --- a/test/Schema.spec.ts +++ b/test/Schema.spec.ts @@ -193,7 +193,7 @@ export class SchemaSpec { continue; } - const type = property.type!; + let type = property.type!; if (isIntrinsicType(type)) { continue; @@ -212,10 +212,24 @@ export class SchemaSpec { fail(`'${thingName}'#'${property.name}' element type '${elementType.type}' is not handled by this test!`); } } else if (isReferenceType(type)) { - expect(SchemaSpec.thingNames).not.to.contain( - type.name, - `Property '${property.name}' on type '${thingName}' has element type '${type.name}'.`, - ); + do { + expect(SchemaSpec.thingNames).not.to.contain( + 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)) { for (const nestedType of type.types) { if (isIntrinsicType(nestedType) || isStringLiteralType(nestedType)) {