Skip to content
Snippets Groups Projects
Commit aa858c74 authored by Alvaro Cabrera's avatar Alvaro Cabrera
Browse files

Type any is not supported; fix

parent f28b6c10
Branches
Tags
No related merge requests found
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -57,13 +57,6 @@
},
"type": "string",
"valid": true
},
{
"description": "should generate any-value",
"schema": {
"type": "any"
},
"type": "any"
}
]
}
......
......@@ -3,19 +3,8 @@ clone = require('clone')
ZSchema = require('z-schema')
JaySchema = require('jayschema')
type = (value) ->
Object::toString.call(value).match(/object (\w+)/)[1].toLowerCase()
jasmine.Matchers::toHaveAnyType = ->
test = type(@actual)
if ['array', 'boolean', 'null', 'number', 'object', 'string'].indexOf(test) is -1
throw "Unexpected type '#{test}' to be any?"
true
jasmine.Matchers::toHaveType = (expected) ->
if type(@actual) isnt expected
if Object::toString.call(@actual).match(/object (\w+)/)[1].toLowerCase() isnt expected
throw "Expected #{JSON.stringify @actual} to have #{expected} type"
true
......
......@@ -29,10 +29,7 @@ glob.sync("#{__dirname}/**/*.json").forEach (file) ->
throw e unless test.throws
if test.type
if test.type is 'any'
expect(sample).toHaveAnyType()
else
expect(sample).toHaveType test.type
expect(sample).toHaveType test.type
if test.valid
expect(sample).toHaveSchema schema, refs
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment