Skip to content

Commit

Permalink
Add test for schema errors with tags named "root"
Browse files Browse the repository at this point in the history
References to "root" should not internally be understood as a reference
to the root tag. The behavior of schemaErrors() was already correct, 
but seeing that this error came up in other areas of the code (e.g. the
Typescript generation), adding this test ensures that schemaErrors() 
stays correct.
  • Loading branch information
MaximeKjaer authored and mbovel committed Aug 30, 2019
1 parent 5013c43 commit 3ed305e
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/schema/schemaErrorsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,34 @@ describe("schemaErrors()", () => {
assert.strictEqual("prop", error.propName);
assert.strictEqual("unknown", error.referencedTag);
});

it("is returned when an unknown 'root' tag is referenced in a body prop", () => {
const schema: SchemaDefinition = {
root: root(prop("body", zeroOrMore("test"))),
blocks: {
["test"]: {
rawBody: false,
props: {
body: {
["prop"]: oneOrMore("root")
}
}
}
},
inline: {
["root"]: inline()
}
};

const errors = schemaErrors(schema);
assert.lengthOf(errors, 1);

const error = errors[0] as UndefinedBlockTagError;
assert.instanceOf(error, UndefinedBlockTagError);
assert.strictEqual("test", error.schemaTag);
assert.strictEqual("prop", error.propName);
assert.strictEqual("root", error.referencedTag);
});
});
});
});

0 comments on commit 3ed305e

Please sign in to comment.