Skip to content

Commit 44e911d

Browse files
committed
Hard-coded test for otherwise unreachable branch
1 parent 4160e31 commit 44e911d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tests/schema/schema.test.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ describe("v3.2", () => {
5252
await expect(oad).to.not.matchJsonSchema("./src/schemas/validation/schema.yaml"); // <-- "schema.yaml" instead of "schema-base.yaml"
5353
});
5454

55+
test("unreachable branch in Reference Object", async () => {
56+
// The Reference Object schema is only conditionally reached if the instance is an object,
57+
// so the `type: object` line will never fail unless "directly" tested with a non-object instance.
58+
const invalidReferenceObject = 42;
59+
await expect(invalidReferenceObject).to.not.matchJsonSchema("./src/schemas/validation/schema.yaml#/$defs/reference"); // <-- "schema.yaml" instead of "schema-base.yaml"
60+
});
61+
5562
describe("Pass", () => {
5663
readdirSync(`${fixtures}/pass`, { withFileTypes: true })
5764
.filter((entry) => entry.isFile() && /\.yaml$/.test(entry.name))

0 commit comments

Comments
 (0)