Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/core/plugins/samples/fn.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const primitives = {
"string": () => "string",
"string_email": () => "user@example.com",
"string_date-time": () => new Date().toISOString(),
"string_date": () => new Date().toISOString().substring(0, 10),
"number": () => 0,
"number_float": () => 0.0,
"integer": () => 0,
Expand Down
22 changes: 22 additions & 0 deletions test/core/plugins/samples/fn.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,28 @@ describe("sampleFromSchema", function() {
expect(sampleFromSchema(definition, { includeWriteOnly: true })).toEqual(expected)
})

it("returns example value for date-time property", function() {
var definition = {
type: "string",
format: "date-time"
}

var expected = new Date().toISOString()

expect(sampleFromSchema(definition)).toEqual(expected)
})

it("returns example value for date property", function() {
var definition = {
type: "string",
format: "date"
}

var expected = new Date().toISOString().substring(0, 10)

expect(sampleFromSchema(definition)).toEqual(expected)
})

describe("for array type", function() {
it("returns array with sample of array type", function() {
var definition = {
Expand Down