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

Improve optionalsProbability tests; fix

parent 006c0902
Branches
No related tags found
No related merge requests found
[
{
"description": "optionalsProbability option",
"schemas": [
{
"type": "object",
"properties": {
"optionalProperty1": { "type": "number", "default": 1 },
"optionalProperty2": { "type": "number", "default": 1 },
"optionalProperty3": { "type": "number", "default": 1 },
"optionalProperty4": { "type": "number", "default": 1 },
"optionalProperty5": { "type": "number", "default": 1 }
}
}
],
"tests": [
{
"description": "should handle optionalsProbability option (default = 0) for objects",
"schema": {
"type": "object",
"properties": {
"optionalProperty1": { "type": "number", "default": 1 },
"optionalProperty2": { "type": "number", "default": 1 },
"optionalProperty3": { "type": "number", "default": 1 },
"optionalProperty4": { "type": "number", "default": 1 },
"optionalProperty5": { "type": "number", "default": 1 }
}
},
"schema": "schemas.0",
"valid": true,
"equal": {}
},
{
"description": "should handle optionalsProbability option (= 1) for objects",
"schema": {
"type": "object",
"properties": {
"optionalProperty1": { "type": "number", "default": 1 },
"optionalProperty2": { "type": "number", "default": 1 },
"optionalProperty3": { "type": "number", "default": 1 },
"optionalProperty4": { "type": "number", "default": 1 },
"optionalProperty5": { "type": "number", "default": 1 }
}
},
"schema": "schemas.0",
"valid": true,
"equal": {
"optionalProperty1": 1,
......@@ -56,16 +50,7 @@
},
{
"description": "should handle optionalsProbability option (= 0) overwritten by alwaysFakeOptionals for objects",
"schema": {
"type": "object",
"properties": {
"optionalProperty1": { "type": "number", "default": 1 },
"optionalProperty2": { "type": "number", "default": 1 },
"optionalProperty3": { "type": "number", "default": 1 },
"optionalProperty4": { "type": "number", "default": 1 },
"optionalProperty5": { "type": "number", "default": 1 }
}
},
"schema": "schemas.0",
"valid": true,
"equal": {
"optionalProperty1": 1,
......@@ -90,6 +75,66 @@
"valid": true,
"equal": ["a", "a", "a", "a", "a"],
"require": "core/option/optionalsProbabilityOverwritten"
},
{
"description": "should generate just zero properties if optionalsProbability is 0%",
"schema": "schemas.0",
"valid": true,
"count": 0,
"set": {
"useDefaultValue": true,
"optionalsProbability": 0.0
}
},
{
"description": "should generate just one property if optionalsProbability is 20%",
"schema": "schemas.0",
"valid": true,
"count": 1,
"set": {
"useDefaultValue": true,
"optionalsProbability": 0.2
}
},
{
"description": "should generate just two properties if optionalsProbability is 40%",
"schema": "schemas.0",
"valid": true,
"count": 2,
"set": {
"useDefaultValue": true,
"optionalsProbability": 0.4
}
},
{
"description": "should generate just three properties if optionalsProbability is 60%",
"schema": "schemas.0",
"valid": true,
"count": 3,
"set": {
"useDefaultValue": true,
"optionalsProbability": 0.6
}
},
{
"description": "should generate just four properties if optionalsProbability is 80%",
"schema": "schemas.0",
"valid": true,
"count": 4,
"set": {
"useDefaultValue": true,
"optionalsProbability": 0.8
}
},
{
"description": "should generate all properties if optionalsProbability is 100%",
"schema": "schemas.0",
"valid": true,
"count": 5,
"set": {
"useDefaultValue": true,
"optionalsProbability": 1.0
}
}
]
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment