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
No related branches found
No related tags found
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 @@ ...@@ -57,13 +57,6 @@
}, },
"type": "string", "type": "string",
"valid": true "valid": true
},
{
"description": "should generate any-value",
"schema": {
"type": "any"
},
"type": "any"
} }
] ]
} }
......
...@@ -3,19 +3,8 @@ clone = require('clone') ...@@ -3,19 +3,8 @@ clone = require('clone')
ZSchema = require('z-schema') ZSchema = require('z-schema')
JaySchema = require('jayschema') 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) -> 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" throw "Expected #{JSON.stringify @actual} to have #{expected} type"
true true
......
...@@ -29,10 +29,7 @@ glob.sync("#{__dirname}/**/*.json").forEach (file) -> ...@@ -29,10 +29,7 @@ glob.sync("#{__dirname}/**/*.json").forEach (file) ->
throw e unless test.throws throw e unless test.throws
if test.type if test.type
if test.type is 'any' expect(sample).toHaveType test.type
expect(sample).toHaveAnyType()
else
expect(sample).toHaveType test.type
if test.valid if test.valid
expect(sample).toHaveSchema schema, refs 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