Simplified the parseEntityRef function

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2022-02-23 13:28:54 +01:00
parent 0ba3149bee
commit 68f0871b76
6 changed files with 41 additions and 114 deletions
@@ -187,7 +187,7 @@ describe('BuiltinKindsEntityProcessor', () => {
await expect(
processor.postProcessEntity(entity, location, emit),
).rejects.toThrowError(
'Entity reference "r" did not specify a kind (e.g. starting with "Component:"), and has no default',
'Entity reference "r" had missing or empty kind (e.g. did not start with "component:" or similar)',
);
});
@@ -360,7 +360,7 @@ describe('BuiltinKindsEntityProcessor', () => {
await expect(
processor.postProcessEntity(entity, location, emit),
).rejects.toThrowError(
'Entity reference "c" did not specify a kind (e.g. starting with "Component:"), and has no default',
'Entity reference "c" had missing or empty kind (e.g. did not start with "component:" or similar)',
);
});
@@ -106,11 +106,6 @@ export class BuiltinKindsEntityProcessor implements CatalogProcessor {
}
for (const target of [targets].flat()) {
const targetRef = parseEntityRef(target, context);
if (targetRef.kind === undefined) {
throw new Error(
`Entity reference "${target}" did not specify a kind (e.g. starting with "Component:"), and has no default`,
);
}
emit(
result.relation({
source: selfRef,