@@ -182,6 +182,66 @@ describe('schema types', () => {
182182 } ) ;
183183 } ) ;
184184
185+ describe ( 'Date value' , ( ) => {
186+ test ( 'it should allow the correct type and enforce the _meta.description' , ( ) => {
187+ let valueType : SchemaValue < Date > = {
188+ type : 'date' ,
189+ _meta : {
190+ description : 'Some description' ,
191+ } ,
192+ } ;
193+
194+ valueType = {
195+ type : 'keyword' ,
196+ _meta : {
197+ description : 'Some description' ,
198+ optional : false ,
199+ } ,
200+ } ;
201+
202+ valueType = {
203+ // @ts -expect-error because the type does not match
204+ type : 'long' ,
205+ _meta : {
206+ description : 'Some description' ,
207+ optional : false ,
208+ } ,
209+ } ;
210+
211+ valueType = {
212+ type : 'keyword' ,
213+ _meta : {
214+ description : 'Some description' ,
215+ // @ts -expect-error optional can't be true when the types don't set the value as optional
216+ optional : true ,
217+ } ,
218+ } ;
219+
220+ // @ts -expect-error because it's missing the _meta.description
221+ valueType = { type : 'date' } ;
222+ expect ( valueType ) . not . toBeUndefined ( ) ; // <-- Only to stop the var-not-used complain
223+ } ) ;
224+ test ( 'it should enforce `_meta.optional: true`' , ( ) => {
225+ let valueType : SchemaValue < Date | undefined > = {
226+ type : 'date' ,
227+ _meta : {
228+ description : 'Some description' ,
229+ optional : true ,
230+ } ,
231+ } ;
232+
233+ valueType = {
234+ type : 'date' ,
235+ _meta : {
236+ description : 'Some description' ,
237+ // @ts -expect-error because optional can't be false when the value can be undefined
238+ optional : false ,
239+ } ,
240+ } ;
241+ expect ( valueType ) . not . toBeUndefined ( ) ; // <-- Only to stop the var-not-used complain
242+ } ) ;
243+ } ) ;
244+
185245 describe ( 'Object value' , ( ) => {
186246 test ( 'it should allow "pass_through" and enforce the _meta.description' , ( ) => {
187247 let valueType : SchemaValue < { a_value : string } > = {
0 commit comments