File tree Expand file tree Collapse file tree 2 files changed +83
-1
lines changed
Expand file tree Collapse file tree 2 files changed +83
-1
lines changed Original file line number Diff line number Diff line change @@ -90,3 +90,33 @@ export const testSchema2 = {
9090 } ,
9191 } ,
9292} as JSONSchema7 ;
93+
94+ export const testSchema3 = {
95+ $ref : "#/definitions/fancyObject" ,
96+ definitions : {
97+ fancyObject : {
98+ type : "object" ,
99+ properties : {
100+ foo : { type : "string" } ,
101+ bar : { type : "number" } ,
102+ } ,
103+ } ,
104+ } ,
105+ } as JSONSchema7 ;
106+
107+ export const testSchema4 = {
108+ allOf : [
109+ {
110+ $ref : "#/definitions/fancyObject" ,
111+ } ,
112+ ] ,
113+ definitions : {
114+ fancyObject : {
115+ type : "object" ,
116+ properties : {
117+ foo : { type : "string" } ,
118+ bar : { type : "number" } ,
119+ } ,
120+ } ,
121+ } ,
122+ } as JSONSchema7 ;
Original file line number Diff line number Diff line change 11import { describe , it } from "vitest" ;
22
3- import { expectCompletion } from "./__helpers__/completion.js" ;
3+ import { expectCompletion } from "./__helpers__/completion" ;
4+ import { testSchema3 , testSchema4 } from "./__fixtures__/schemas" ;
45
56describe ( "jsonCompletion" , ( ) => {
67 it ( "should return completion data for simple types" , async ( ) => {
@@ -291,6 +292,57 @@ describe("jsonCompletion", () => {
291292 } ,
292293 ] ) ;
293294 } ) ;
295+ it ( "should autocomplete for array of objects with filter" , async ( ) => {
296+ await expectCompletion ( '{ "arrayOfObjects": [ { "f|" } ] }' , [
297+ {
298+ detail : "string" ,
299+ info : "" ,
300+ label : "foo" ,
301+ template : '"foo": "#{}"' ,
302+ type : "property" ,
303+ } ,
304+ ] ) ;
305+ } ) ;
306+ it ( "should autocomplete for a schema with top level $ref" , async ( ) => {
307+ await expectCompletion (
308+ '{ "| }' ,
309+ [
310+ {
311+ type : "property" ,
312+ detail : "string" ,
313+ info : "" ,
314+ label : "foo" ,
315+ } ,
316+ {
317+ type : "property" ,
318+ detail : "number" ,
319+ info : "" ,
320+ label : "bar" ,
321+ } ,
322+ ] ,
323+ { schema : testSchema3 }
324+ ) ;
325+ } ) ;
326+ it ( "should autocomplete for a schema with top level complex type" , async ( ) => {
327+ await expectCompletion (
328+ '{ "| }' ,
329+ [
330+ {
331+ type : "property" ,
332+ detail : "string" ,
333+ info : "" ,
334+ label : "foo" ,
335+ } ,
336+ {
337+ type : "property" ,
338+ detail : "number" ,
339+ info : "" ,
340+ label : "bar" ,
341+ } ,
342+ ] ,
343+ { schema : testSchema4 }
344+ ) ;
345+ } ) ;
294346} ) ;
295347
296348describe ( "json5Completion" , ( ) => {
You can’t perform that action at this time.
0 commit comments