fbp-spec
Version:
Data-driven FBP component/graph testing tool
391 lines • 8.67 kB
JavaScript
window.fbpspec_examples = {
"jsonpath.yaml": {
"name": "Using JSONPath in expectations",
"topic": "core/Repeat",
"fixture": {
"type": "fbp",
"data": "# @runtime python-example\n\nINPORT=it.IN:IN\nOUTPORT=f.OUT:OUT\n\nit(core/Repeat) OUT -> IN f(core/Repeat)\n"
},
"cases": [
{
"name": "select single value",
"assertion": "should pass",
"inputs": {
"in": {
"outer": {
"inner": {
"foo": "bar"
}
}
}
},
"expect": {
"out": {
"path": "$.outer.inner.foo",
"equals": "bar"
}
}
},
{
"name": "selecting non-existent value",
"assertion": "should fail",
"inputs": {
"in": {
"outer": {
"inner": {
"foo": "bar"
}
}
}
},
"expect": {
"out": {
"path": "$.outer.nonexist",
"equals": "bar"
}
}
},
{
"name": "selecting many correct values",
"assertion": "should pass",
"inputs": {
"in": {
"outer": {
"first": {
"foo": "bar"
},
"second": {
"foo": "bar"
}
}
}
},
"expect": {
"out": {
"path": "$.outer.*.foo",
"equals": "bar"
}
}
},
{
"name": "selecting many values, some failing",
"assertion": "should fail",
"inputs": {
"in": {
"outer": {
"first": {
"foo": "bar"
},
"second": {
"foo": "bar"
},
"third": {
"foo": "bazz"
}
}
}
},
"expect": {
"out": {
"path": "$.outer.*.foo",
"equals": "bar"
}
}
}
]
},
"multisuite-failandpass.yaml": [
{
"name": "MultiSuite, failing tests",
"topic": "core/Repeat",
"fixture": {
"type": "fbp",
"data": "# @runtime python-example\n\nINPORT=it.IN:IN\nOUTPORT=f.OUT:OUT\n\nit(core/Repeat) OUT -> IN f(core/Repeat)\n"
},
"cases": [
{
"name": "sending a boolean with wrong expect",
"assertion": "should fail",
"inputs": {
"in": true
},
"expect": {
"out": {
"equals": false
}
}
},
{
"name": "sending a number with wrong expect",
"assertion": "should fail",
"inputs": {
"in": 1000
},
"expect": {
"out": {
"equals": 1003
}
}
}
]
},
{
"name": "MultiSuite, passing tests",
"topic": "core/Repeat",
"fixture": {
"type": "fbp",
"data": "# @runtime python-example\n\nINPORT=it.IN:IN\nOUTPORT=f.OUT:OUT\n\nit(core/Repeat) OUT -> IN f(core/Repeat)\n"
},
"cases": [
{
"name": "sending a boolean",
"assertion": "should repeat the same",
"inputs": {
"in": true
},
"expect": {
"out": {
"equals": true
}
}
},
{
"name": "sending a number",
"assertion": "should repeat the same",
"inputs": {
"in": 1000
},
"expect": {
"out": {
"equals": 1000
}
}
}
]
}
],
"predicates.yaml": {
"name": "Different predicates",
"topic": "core/Repeat",
"fixture": {
"type": "fbp",
"data": "# @runtime python-example\n\nINPORT=it.IN:IN\nOUTPORT=f.OUT:OUT\n\nit(core/Repeat) OUT -> IN f(core/Repeat)\n"
},
"cases": [
{
"name": "equals with correct expect",
"assertion": "should pass",
"inputs": {
"in": true
},
"expect": {
"out": {
"equals": true
}
}
},
{
"name": "equals with wrong expect",
"assertion": "should fail",
"inputs": {
"in": true
},
"expect": {
"out": {
"equals": false
}
}
},
{
"name": "above with wrong expect",
"assertion": "should fail",
"inputs": {
"in": 1000
},
"expect": {
"out": {
"above": 1001
}
}
},
{
"name": "haveKeys with correct expect",
"assertion": "should pass",
"inputs": {
"in": {
"foo": "bar"
}
},
"expect": {
"out": {
"haveKeys": [
"foo"
]
}
}
},
{
"name": "type with correct expectation",
"assertion": "should pass",
"inputs": {
"in": {
"foo": "bar"
}
},
"expect": {
"out": {
"type": "object"
}
}
},
{
"name": "includeKeys with correct expect",
"assertion": "should pass",
"inputs": {
"in": {
"foo": "bar",
"foo2": "baz"
}
},
"expect": {
"out": {
"includeKeys": [
"foo"
]
}
}
},
{
"name": "includeKeys with wrong expect",
"assertion": "should fail",
"inputs": {
"in": {
"foo": "bar",
"foo2": "baz"
}
},
"expect": {
"out": {
"includeKeys": [
"foo",
"foo3"
]
}
}
},
{
"name": "contains on string with correct expect",
"assertion": "should pass",
"inputs": {
"in": "my string with a substring 22"
},
"expect": {
"out": {
"contains": "substring"
}
}
},
{
"name": "contains on string with wrong expect",
"assertion": "should fail",
"inputs": {
"in": "my string with a substring 22"
},
"expect": {
"out": {
"contains": "substring 3"
}
}
},
{
"name": "multiple expectations on one value, one wrong",
"assertion": "should fail",
"inputs": {
"in": {
"foo": "bar"
}
},
"expect": {
"out": [
{
"type": "object"
},
{
"haveKeys": [
"nonexist"
]
}
]
}
}
]
},
"simple-failing.yaml": {
"name": "Simple example of failing tests",
"topic": "core/Repeat",
"fixture": {
"type": "fbp",
"data": "# @runtime python-example\n\nINPORT=it.IN:IN\nOUTPORT=f.OUT:OUT\n\nit(core/Repeat) OUT -> IN f(core/Repeat)\n"
},
"cases": [
{
"name": "sending a boolean with wrong expect",
"assertion": "should fail",
"inputs": {
"in": true
},
"expect": {
"out": {
"equals": false
}
}
},
{
"name": "sending a number with wrong expect",
"assertion": "should fail",
"inputs": {
"in": 1000
},
"expect": {
"out": {
"equals": 1003
}
}
}
]
},
"simple-passing.yaml": {
"name": "Simple example of passing tests",
"topic": "core/Repeat",
"fixture": {
"type": "fbp",
"data": "# @runtime python-example\n\nINPORT=it.IN:IN\nOUTPORT=f.OUT:OUT\n\nit(core/Repeat) OUT -> IN f(core/Repeat)\n"
},
"cases": [
{
"name": "sending a boolean",
"assertion": "should repeat the same",
"inputs": {
"in": true
},
"expect": {
"out": {
"equals": true
}
}
},
{
"name": "sending a number",
"assertion": "should repeat the same",
"inputs": {
"in": 1000
},
"expect": {
"out": {
"equals": 1000
}
}
}
]
}
};