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

Merge branch 'develop'

parents c2e907e1 1db93753
Branches
Tags
No related merge requests found
......@@ -4,4 +4,5 @@
.DS_Store
/package
/reports
/generated
/node_modules
......@@ -7,4 +7,5 @@ Gruntfile.js
/spec
/package
/reports
/generated
/node_modules
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.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
{
"name": "json-schema-faker",
"version": "0.1.5",
"version": "0.1.6",
"description": "JSON-Schema + Faker",
"main": "lib/index.js",
"author": {
......@@ -16,15 +16,15 @@
"clone": "^0.1.19",
"glob": "^4.3.5",
"grunt": "^0.4.5",
"grunt-parts": "^0.3.0",
"grunt-parts": "^0.3.1",
"jayschema": "^0.3.1",
"semver": "^4.2.0",
"tv4": "^1.1.5",
"tv4": "^1.1.9",
"z-schema": "^3.3.1"
},
"dependencies": {
"chance": "^0.6.4",
"deref": "^0.2.6",
"chance": "^0.7.4",
"deref": "^0.2.8",
"faker": "^2.1.2",
"randexp": "^0.4.0"
}
......
......@@ -3,6 +3,7 @@
"description": "sub-schema mixins",
"schemas": [
{
"id": "#",
"type": "object",
"definitions": {
"inner": {
......
[
{
"description": "chance issues",
"tests": [
{
"description": "should allow url-format (0.7.1+)",
"schema": {
"type": "string",
"chance": "url"
},
"valid": true
}
]
}
]
......@@ -17,6 +17,23 @@
"format": "semver"
},
"valid": true
},
{
"description": "should support faker/chance on numeric types",
"schema": {
"type": "object",
"properties": {
"chanceNumber": {
"type": "integer",
"chance": "natural"
},
"fakerNumber": {
"type": "integer",
"faker": "random.number"
}
}
},
"valid": true
}
]
}
......
......@@ -5,7 +5,7 @@
{
"description": "should handle array of types",
"schema": {
"type": ["string", "number"]
"type": ["string", "integer"]
},
"valid": true
},
......@@ -35,7 +35,7 @@
"schema": {
"anyOf": [
{
"type": "number"
"type": "integer"
},
{
"type": "array"
......
......@@ -4,10 +4,11 @@
"tests": [
{
"description": "should handle internal $refs",
"schema": {
"schema": {
"id": "#",
"definitions": {
"number": {
"type": "number"
"integer": {
"type": "integer"
},
"positive": {
"minimum": 0,
......@@ -17,7 +18,7 @@
"type": "object",
"properties": {
"weakNumber": {
"$ref": "#/definitions/number"
"$ref": "#/definitions/integer"
},
"multipleOf5": {
"allOf": [
......@@ -25,7 +26,7 @@
"$ref": "#/definitions/positive"
},
{
"$ref": "#/definitions/number"
"$ref": "#/definitions/integer"
},
{
"multipleOf": 5
......
[
{
"description": "generated number values",
"description": "generated integer values",
"tests": [
{
"description": "should handle minimum",
"schema": {
"type": "number",
"type": "integer",
"minimum": 10
},
"hasNot": ".",
"type": "number",
"valid": true
},
{
"description": "should handle maximum",
"schema": {
"type": "number",
"type": "integer",
"minimum": 20,
"maximum": 30
},
"hasNot": ".",
"type": "number",
"valid": true
},
{
"description": "should handle multipleOf",
"schema": {
"type": "number",
"type": "integer",
"minimum": 40,
"maximum": 50,
"multipleOf": 6
},
"hasNot": ".",
"type": "number",
"valid": true
},
{
"description": "should handle exclusiveMinimum",
"schema": {
"type": "number",
"type": "integer",
"minimum": 60,
"maximum": 70,
"multipleOf": 7,
"exclusiveMinimum": true
},
"hasNot": ".",
"type": "number",
"valid": true
},
{
"description": "should handle exclusiveMaximum",
"schema": {
"type": "number",
"type": "integer",
"minimum": 80,
"maximum": 90,
"multipleOf": 8,
"exclusiveMinimum": true,
"exclusiveMaximum": true
},
"hasNot": ".",
"type": "number",
"valid": true
},
{
......@@ -58,7 +68,7 @@
"type": "object",
"properties": {
"test": {
"type": "number",
"type": "integer",
"minimum": []
}
}
......@@ -71,7 +81,7 @@
"type": "object",
"properties": {
"test": {
"type": "number",
"type": "integer",
"maximum": []
}
}
......@@ -84,7 +94,7 @@
"type": "object",
"properties": {
"test": {
"type": "number",
"type": "integer",
"minimum": 100,
"maximum": 50
}
......
......@@ -47,7 +47,7 @@ jasmine.Matchers::toHaveSchema = (expected, refs) ->
formatValidators jay
jay.register(clone(schema), schema.id) for schema in refs if refs
jay.register(clone(schema)) for schema in refs if refs
result = jay.validate @actual, clone(expected)
......
fs = require('fs')
glob = require('glob')
deref = require('deref')
jsfaker = require('../lib')
require('./formats').register(jsfaker)
......@@ -43,6 +44,9 @@ glob.sync("#{__dirname}/**/*.json").forEach (file) ->
error = e.message
throw e unless test.throws
if test.hasNot
expect(sample.toString()).not.toContain test.hasNot
if test.type
expect(sample).toHaveType test.type
......@@ -50,7 +54,10 @@ glob.sync("#{__dirname}/**/*.json").forEach (file) ->
expect(error).toMatch new RegExp('^' + test.throws + '$', 'i')
if test.valid
schema = deref.util.normalizeSchema(schema)
try
refs = [schema] if schema.id
expect(sample).toHaveSchema schema, refs
catch e
console.log JSON.stringify(schema, null, 2)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment