@@ -30,6 +30,137 @@ describe("jsonCompletion", () => {
30
30
info : "" ,
31
31
template : '"oneOfEg2": ' ,
32
32
} ,
33
+ {
34
+ detail : "" ,
35
+ info : "" ,
36
+ label : "oneOfObject" ,
37
+ template : '"oneOfObject": ' ,
38
+ type : "property" ,
39
+ } ,
40
+ ] ) ;
41
+ } ) ;
42
+ it ( "should include defaults for enum when available" , async ( ) => {
43
+ await expectCompletion ( '{ "en| }' , [
44
+ {
45
+ label : "enum1" ,
46
+ type : "property" ,
47
+ detail : "" ,
48
+ info : "an example enum with default bar" ,
49
+ // TODO: should this not autocomplete to default "bar"?
50
+ // template: '"enum1": "${bar}"',
51
+ template : '"enum1": #{}' ,
52
+ } ,
53
+ {
54
+ label : "enum2" ,
55
+ type : "property" ,
56
+ detail : "" ,
57
+ info : "an example enum without default" ,
58
+ template : '"enum2": #{}' ,
59
+ } ,
60
+ ] ) ;
61
+ } ) ;
62
+ it ( "should include value completions for enum" , async ( ) => {
63
+ await expectCompletion ( '{ "enum1": "|" }' , [
64
+ {
65
+ label : '"foo"' ,
66
+ info : "an example enum with default bar" ,
67
+ } ,
68
+ {
69
+ label : '"bar"' ,
70
+ detail : "Default value" ,
71
+ } ,
72
+ ] ) ;
73
+ } ) ;
74
+ it ( "should include defaults for boolean when available" , async ( ) => {
75
+ await expectCompletion ( '{ "booleanW| }' , [
76
+ {
77
+ type : "property" ,
78
+ detail : "boolean" ,
79
+ info : "an example boolean with default" ,
80
+ label : "booleanWithDefault" ,
81
+ template : '"booleanWithDefault": ${true}' ,
82
+ } ,
83
+ ] ) ;
84
+ } ) ;
85
+ // TODO: should provide true/false completions
86
+ it ( "should include value completions for boolean" , async ( ) => {
87
+ await expectCompletion ( '{ "booleanWithDefault": | }' , [ ] ) ;
88
+ } ) ;
89
+ it ( "should include insert text for objects" , async ( ) => {
90
+ await expectCompletion ( '{ "ob| }' , [
91
+ {
92
+ type : "property" ,
93
+ detail : "object" ,
94
+ info : "" ,
95
+ label : "object" ,
96
+ template : '"object": {#{}}' ,
97
+ } ,
98
+ ] ) ;
99
+ } ) ;
100
+ // this has regressed for json4 only for some reason
101
+ it ( "should include insert text for nested object properties" , async ( ) => {
102
+ await expectCompletion ( '{ "object": { "|" } }' , [
103
+ {
104
+ detail : "string" ,
105
+ info : "an elegant string" ,
106
+ label : "foo" ,
107
+ template : '"foo": "#{}"' ,
108
+ type : "property" ,
109
+ } ,
110
+ ] ) ;
111
+ } ) ;
112
+ it ( "should include insert text for nested object properties with filter" , async ( ) => {
113
+ await expectCompletion ( '{ "object": { "f|" } }' , [
114
+ {
115
+ detail : "string" ,
116
+ info : "an elegant string" ,
117
+ label : "foo" ,
118
+ template : '"foo": "#{}"' ,
119
+ type : "property" ,
120
+ } ,
121
+ ] ) ;
122
+ } ) ;
123
+ it ( "should autocomplete for oneOf with nested definitions and filter" , async ( ) => {
124
+ await expectCompletion ( '{ "oneOfObject": { "f|" } }' , [
125
+ {
126
+ detail : "string" ,
127
+ info : "" ,
128
+ label : "foo" ,
129
+ template : '"foo": "#{}"' ,
130
+ type : "property" ,
131
+ } ,
132
+ ] ) ;
133
+ } ) ;
134
+ it ( "should autocomplete for oneOf with nested definitions" , async ( ) => {
135
+ await expectCompletion ( '{ "oneOfObject": { "|" } }' , [
136
+ {
137
+ detail : "string" ,
138
+ info : "" ,
139
+ label : "foo" ,
140
+ template : '"foo": "#{}"' ,
141
+ type : "property" ,
142
+ } ,
143
+ {
144
+ detail : "number" ,
145
+ info : "" ,
146
+ label : "bar" ,
147
+ template : '"bar": #{0}' ,
148
+ type : "property" ,
149
+ } ,
150
+ {
151
+ detail : "string" ,
152
+ info : "" ,
153
+ label : "apple" ,
154
+ template : '"apple": "#{}"' ,
155
+ type : "property" ,
156
+ } ,
157
+ {
158
+ detail : "number" ,
159
+ info : "" ,
160
+ label : "banana" ,
161
+ template : '"banana": #{0}' ,
162
+ type : "property" ,
163
+ } ,
33
164
] ) ;
34
165
} ) ;
35
166
} ) ;
0 commit comments