Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tests #141

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Update tests #141

wants to merge 1 commit into from

Conversation

colearendt
Copy link

Update tests to the most recent version of https://github.com/json-schema-org/JSON-Schema-Test-Suite draft4.

Thought this might be useful to ensuring edge cases are successful.

@LinusU
Copy link
Collaborator

LinusU commented Jun 19, 2017

Seems like a few tests are failing now, care to investigate? :)

@colearendt
Copy link
Author

I'm game to give it a shot. I'm not much of a JavaScript developer, but maybe I can get an idea of where the problem is.

@colearendt
Copy link
Author

colearendt commented Jun 20, 2017

The failing tests. Enumerating before digging further:

# json-schema-test-suite ECMA 262 regex non-compliance
not ok 67 ECMA 262 has no support for \Z anchor from .NET
  ---
    operator: deepEqual
    expected: false
    actual:   true
    at: Test.<anonymous> (/home/travis/build/mafintosh/is-my-json-valid/test/json-schema.js:17:15)
  ...

## TEST
[
    {
        "description": "ECMA 262 regex non-compliance",
        "schema": { "format": "regex" },
        "tests": [
            {
                "description": "ECMA 262 has no support for \\Z anchor from .NET",
                "data": "^\\S(|(.|\\n)*\\S)\\Z",
                "valid": false
            }
        ]
    }
]
# json-schema-test-suite an array of schemas for items
not ok 108 JavaScript pseudo-array is valid
  ---
    operator: deepEqual
    expected: true
    actual:   false
    at: Test.<anonymous> (/home/travis/build/mafintosh/is-my-json-valid/test/json-schema.js:17:15)
  ...

## TEST
[
    {
        "description": "a schema given for items",
        "schema": {
            "items": {"type": "integer"}
        },
        "tests": [
            {
                "description": "JavaScript pseudo-array is valid",
                "data": {
                    "0": "invalid",
                    "length": 1
                },
                "valid": true
            }
        ]
    },
    {
        "description": "an array of schemas for items",
        "schema": {
            "items": [
                {"type": "integer"},
                {"type": "string"}
            ]
        },
        "tests": [
            {
                "description": "JavaScript pseudo-array is valid",
                "data": {
                    "0": "invalid",
                    "1": "valid",
                    "length": 2
                },
                "valid": true
            }
        ]
    }
]
# json-schema-test-suite maxLength validation
not ok 117 two supplementary Unicode code points is long enough
  ---
    operator: deepEqual
    expected: true
    actual:   false
    at: Test.<anonymous> (/home/travis/build/mafintosh/is-my-json-valid/test/json-schema.js:17:15)
  ...

## TEST
[
    {
        "description": "maxLength validation",
        "schema": {"maxLength": 2},
        "tests": [
            {
                "description": "two supplementary Unicode code points is long enough",
                "data": "\uD83D\uDCA9\uD83D\uDCA9",
                "valid": true
            }
        ]
    }
]
# json-schema-test-suite minLength validation
not ok 136 one supplementary Unicode code point is not long enough
  ---
    operator: deepEqual
    expected: false
    actual:   true
    at: Test.<anonymous> (/home/travis/build/mafintosh/is-my-json-valid/test/json-schema.js:17:15)
  ...

## TEST
[
    {
        "description": "minLength validation",
        "schema": {"minLength": 2},
        "tests": [
            {
                "description": "one supplementary Unicode code point is not long enough",
                "data": "\uD83D\uDCA9",
                "valid": false
            }
        ]
    }
]
# json-schema-test-suite ref overrides any sibling keywords
not ok 224 ref valid, maxItems ignored
  ---
    operator: deepEqual
    expected: true
    actual:   false
    at: Test.<anonymous> (/home/travis/build/mafintosh/is-my-json-valid/test/json-schema.js:17:15)
  ...
[
  {
        "description": "ref overrides any sibling keywords",
        "schema": {
            "definitions": {
                "reffed": {
                    "type": "array"
                }
            },
            "properties": {
                "foo": {
                    "$ref": "#/definitions/reffed",
                    "maxItems": 2
                }
            }
        },
        "tests": [
            {
                "description": "ref valid",
                "data": { "foo": [] },
                "valid": true
            },
            {
                "description": "ref valid, maxItems ignored",
                "data": { "foo": [ 1, 2, 3] },
                "valid": true
            },
            {
                "description": "ref invalid",
                "data": { "foo": "string" },
                "valid": false
            }
        ]
    }
]
# json-schema-test-suite remote ref, containing refs itself
ok 226 remote ref valid
not ok 227 remote ref invalid
  ---
    operator: deepEqual
    expected: false
    actual:   true
    at: Test.<anonymous> (/home/travis/build/mafintosh/is-my-json-valid/test/json-schema.js:17:15)
  ...

## relevant?  I saw a note about remote refs not supported
## TEST
[
{
        "description": "remote ref, containing refs itself",
        "schema": {"$ref": "http://json-schema.org/draft-04/schema#"},
        "tests": [
            {
                "description": "remote ref valid",
                "data": {"minLength": 1},
                "valid": true
            },
            {
                "description": "remote ref invalid",
                "data": {"minLength": -1},
                "valid": false
            }
        ]
    }
]
# json-schema-test-suite Recursive references between schemas
ok 230 valid tree
not ok 231 invalid tree
  ---
    operator: deepEqual
    expected: false
    actual:   true
    at: Test.<anonymous> (/home/travis/build/mafintosh/is-my-json-valid/test/json-schema.js:17:15)
  ...

## TEST
[
{
        "description": "Recursive references between schemas",
        "schema": {
            "id": "http://localhost:1234/tree",
            "description": "tree of nodes",
            "type": "object",
            "properties": {
                "meta": {"type": "string"},
                "nodes": {
                    "type": "array",
                    "items": {"$ref": "node"}
                }
            },
            "required": ["meta", "nodes"],
            "definitions": {
                "node": {
                    "id": "http://localhost:1234/node",
                    "description": "node",
                    "type": "object",
                    "properties": {
                        "value": {"type": "number"},
                        "subtree": {"$ref": "tree"}
                    },
                    "required": ["value"]
                }
            }
        },
        "tests": [
            {
                "description": "valid tree",
                "data": { 
                    "meta": "root",
                    "nodes": [
                        {
                            "value": 1,
                            "subtree": {
                                "meta": "child",
                                "nodes": [
                                    {"value": 1.1},
                                    {"value": 1.2}
                                ]
                            }
                        },
                        {
                            "value": 2,
                            "subtree": {
                                "meta": "child",
                                "nodes": [
                                    {"value": 2.1},
                                    {"value": 2.2}
                                ]
                            }
                        }
                    ]
                },
                "valid": true
            },
            {
                "description": "invalid tree",
                "data": { 
                    "meta": "root",
                    "nodes": [
                        {
                            "value": 1,
                            "subtree": {
                                "meta": "child",
                                "nodes": [
                                    {"value": "string is invalid"},
                                    {"value": 1.2}
                                ]
                            }
                        },
                        {
                            "value": 2,
                            "subtree": {
                                "meta": "child",
                                "nodes": [
                                    {"value": 2.1},
                                    {"value": 2.2}
                                ]
                            }
                        }
                    ]
                },
                "valid": false
            }
        ]
    }
]
# json-schema-test-suite some languages do not distinguish between different types of numeric value
not ok 308 a float is not an integer even without fractional part
  ---
    operator: deepEqual
    expected: false
    actual:   true
    at: Test.<anonymous> (/home/travis/build/mafintosh/is-my-json-valid/test/json-schema.js:17:15)
  ...

## TEST
[
    {
        "description": "some languages do not distinguish between different types of numeric value",
        "schema": {
            "type": "integer"
        },
        "tests": [
            {
                "description": "a float is not an integer even without fractional part",
                "data": 1.0,
                "valid": false
            }
        ]
    }
]

Copy link

@Hbutlercapone Hbutlercapone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve update tests #141

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants