File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
test/core/plugins/samples Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ const primitives = {
66 "string" : ( ) => "string" ,
77 "string_email" :
( ) => "[email protected] " , 88 "string_date-time" : ( ) => new Date ( ) . toISOString ( ) ,
9+ "string_date" : ( ) => new Date ( ) . toISOString ( ) . substring ( 0 , 10 ) ,
910 "number" : ( ) => 0 ,
1011 "number_float" : ( ) => 0.0 ,
1112 "integer" : ( ) => 0 ,
Original file line number Diff line number Diff line change @@ -238,6 +238,28 @@ describe("sampleFromSchema", function() {
238238 expect ( sampleFromSchema ( definition , { includeWriteOnly : true } ) ) . toEqual ( expected )
239239 } )
240240
241+ it ( "returns example value for date-time property" , function ( ) {
242+ var definition = {
243+ type : "string" ,
244+ format : "date-time"
245+ }
246+
247+ var expected = new Date ( ) . toISOString ( )
248+
249+ expect ( sampleFromSchema ( definition ) ) . toEqual ( expected )
250+ } )
251+
252+ it ( "returns example value for date property" , function ( ) {
253+ var definition = {
254+ type : "string" ,
255+ format : "date"
256+ }
257+
258+ var expected = new Date ( ) . toISOString ( ) . substring ( 0 , 10 )
259+
260+ expect ( sampleFromSchema ( definition ) ) . toEqual ( expected )
261+ } )
262+
241263 describe ( "for array type" , function ( ) {
242264 it ( "returns array with sample of array type" , function ( ) {
243265 var definition = {
You can’t perform that action at this time.
0 commit comments