Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
acao committed Nov 8, 2023
1 parent 10f6e46 commit 7ccd833
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/__tests__/json-hover.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ describe("JSONHover#getHoverTexts", () => {
);
expect(hoverTexts).toEqual({
message: "an example oneOf",
typeInfo: "oneOf: `string`, `array`, or `boolean`",
typeInfo:
"oneOf: <code>string</code>, <code>array</code>, or <code>boolean</code>",
});
});
it("should provide oneOf texts with valid values", async () => {
Expand All @@ -86,7 +87,8 @@ describe("JSONHover#getHoverTexts", () => {
);
expect(hoverTexts).toEqual({
message: "an example oneOf",
typeInfo: "oneOf: `string`, `array`, or `boolean`",
typeInfo:
"oneOf: <code>string</code>, <code>array</code>, or <code>boolean</code>",
});
});
});
Expand Down
16 changes: 11 additions & 5 deletions src/__tests__/json-validation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,24 @@ const expectErrors = (
describe("json-validation", () => {
it("should provide range for a value error", () => {
expectErrors('{"foo": 123}', [
[8, 11, "Expected `string` but received `number`"],
[8, 11, "Expected <code>string</code> but received <code>number</code>"],
]);
});
it("should provide range for an unknown key error", () => {
expectErrors('{"foo": "example", "bar": 123}', [
[19, 24, "Additional property `bar` is not allowed"],
[19, 24, "Additional property <code>bar</code> is not allowed"],
]);
});
it("should not handle invalid json", () => {
expectErrors('{"foo": "example" "bar": 123}', []);
});
it("should provide range for invalid multline json", () => {
it("should provide range for invalid multiline json", () => {
expectErrors(
`{
"foo": "example",
"bar": "something else"
}`,
[[32, 37, "Additional property `bar` is not allowed"]]
[[32, 37, "Additional property <code>bar</code> is not allowed"]]
);
});
it("should provide formatted error message for oneOf fields with more than 2 items", () => {
Expand All @@ -63,7 +63,13 @@ describe("json-validation", () => {
"foo": "example",
"oneOfEg": 123
}`,
[[43, 46, 'Expected one of `"string"`, `"array"`, or `"boolean"`']],
[
[
43,
46,
"Expected one of <code>string</code>, <code>array</code>, or <code>boolean</code>",
],
],
testSchema2
);
});
Expand Down

0 comments on commit 7ccd833

Please sign in to comment.