Skip to content

Commit

Permalink
test(validator): validate property groups
Browse files Browse the repository at this point in the history
  • Loading branch information
Niklas Kiefer committed Feb 3, 2022
1 parent 98a0810 commit 036deb0
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 9 deletions.
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
],
"license": "MIT",
"dependencies": {
"@bpmn-io/element-templates-validator": "^0.3.0",
"@bpmn-io/element-templates-validator": "^0.4.0",
"@bpmn-io/extract-process-variables": "^0.4.4",
"array-move": "^3.0.1",
"classnames": "^2.3.1",
Expand Down
37 changes: 37 additions & 0 deletions test/spec/provider/element-templates/Validator.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -594,5 +594,42 @@ describe('provider/element-templates - Validator', function() {
});


describe('grouping', function() {

it('should accept groups', function() {

// given
const templates = new Validator();

const templateDescriptor = require('./fixtures/groups');

// when
templates.addAll(templateDescriptor);

// then
expect(errors(templates)).to.be.empty;

expect(valid(templates)).to.have.length(templateDescriptor.length);
});


it('should not accept missing group id', function() {

// given
const templates = new Validator();

const templateDescriptor = require('./fixtures/error-groups-missing-id');

// when
templates.addAll(templateDescriptor);

// then
expect(errors(templates)).to.contain('template(id: <example.com.missingGroupId>, name: <Missing group id>): missing id for group "0"');

expect(valid(templates)).to.be.empty;
});

});

});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[
{
"name": "Missing group id",
"id": "example.com.missingGroupId",
"appliesTo": [
"bpmn:ServiceTask"
],
"properties": [],
"groups": [
{
"label": "Group one"
},
{
"id": "two",
"label": "Group two"
},
{
"id": "three",
"label": "Group three"
}
]
}
]
69 changes: 69 additions & 0 deletions test/spec/provider/element-templates/fixtures/groups.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
[
{
"name": "Grouping",
"id": "example.com.grouping",
"appliesTo": [
"bpmn:ServiceTask"
],
"properties": [
{
"label": "input 1",
"type": "String",
"binding": {
"type": "camunda:inputParameter",
"name": "input1"
}
},
{
"label": "input 2",
"group": "one",
"type": "String",
"binding": {
"type": "camunda:inputParameter",
"name": "input2"
}
},
{
"label": "input 3",
"group": "one",
"type": "String",
"binding": {
"type": "camunda:inputParameter",
"name": "input3"
}
},
{
"label": "input 4",
"group": "two",
"type": "String",
"binding": {
"type": "camunda:inputParameter",
"name": "input4"
}
},
{
"label": "input 5",
"group": "three",
"type": "String",
"binding": {
"type": "camunda:inputParameter",
"name": "input5"
}
}
],
"groups": [
{
"id": "one",
"label": "Group one"
},
{
"id": "two",
"label": "Group two"
},
{
"id": "three",
"label": "Group three"
}
]
}
]

0 comments on commit 036deb0

Please sign in to comment.