Skip to content

Commit

Permalink
fix(const): type should not be added when using const
Browse files Browse the repository at this point in the history
  • Loading branch information
peyerluk authored and marcbachmann committed Apr 25, 2021
1 parent e490e5b commit 6fd4fc3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 0 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ module.exports = {

const (value) {
return decorate(this, {
type: getJsonType(value),
const: value
})
},
Expand Down
14 changes: 13 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,23 @@ test('enum() creates an enum from an array', function (t) {
test('const() creates a const value', function (t) {
const schema = ms.const('foo')
assert.deepEqual(schema, {
type: 'string',
const: 'foo'
})
})

test('const() creates a required const value', function (t) {
const schema = ms.obj({
foo: ms.required.const('bar')
})
assert.deepEqual(schema, {
type: 'object',
required: ['foo'],
properties: {
foo: {const: 'bar'}
}
})
})


test('arrayOf() creates an array with a type of its items', function (t) {
const schema = ms.arrayOf('integer')
Expand Down

0 comments on commit 6fd4fc3

Please sign in to comment.