diff --git a/src/__tests__/json-completion.spec.ts b/src/__tests__/json-completion.spec.ts index e3f03ba..4f7a0eb 100644 --- a/src/__tests__/json-completion.spec.ts +++ b/src/__tests__/json-completion.spec.ts @@ -1,6 +1,7 @@ import { describe, it } from "vitest"; -import { expectCompletion } from "./__helpers__/completion.js"; +import { expectCompletion } from "./__helpers__/completion"; +import { testSchema3, testSchema4 } from "./__fixtures__/schemas"; describe("jsonCompletion", () => { it("should return completion data for simple types", async () => { @@ -291,6 +292,57 @@ describe("jsonCompletion", () => { }, ]); }); + it("should autocomplete for array of objects with filter", async () => { + await expectCompletion('{ "arrayOfObjects": [ { "f|" } ] }', [ + { + detail: "string", + info: "", + label: "foo", + template: '"foo": "#{}"', + type: "property", + }, + ]); + }); + it("should autocomplete for a schema with top level $ref", async () => { + await expectCompletion( + '{ "| }', + [ + { + type: "property", + detail: "string", + info: "", + label: "foo", + }, + { + type: "property", + detail: "number", + info: "", + label: "bar", + }, + ], + { schema: testSchema3 } + ); + }); + it("should autocomplete for a schema with top level complex type", async () => { + await expectCompletion( + '{ "| }', + [ + { + type: "property", + detail: "string", + info: "", + label: "foo", + }, + { + type: "property", + detail: "number", + info: "", + label: "bar", + }, + ], + { schema: testSchema4 } + ); + }); }); describe("json5Completion", () => {