Skip to content

Commit

Permalink
fix: ignore null properties
Browse files Browse the repository at this point in the history
  • Loading branch information
philippfromme committed Aug 5, 2022
1 parent daab537 commit 9d2dcb9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
3 changes: 2 additions & 1 deletion rules/utils/element.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const {
isArray,
isDefined,
isNil,
some
} = require('min-dash');

Expand Down Expand Up @@ -147,7 +148,7 @@ module.exports.hasProperties = function(node, properties, parentNode = null) {
];
}

if (propertyChecks.allowed === false && isDefined(propertyValue)) {
if (propertyChecks.allowed === false && isDefined(propertyValue) && !isNil(propertyValue)) {
return [
...results,
{
Expand Down
2 changes: 1 addition & 1 deletion test/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function createElement(type, properties) {
};

const setParent = (property) => {
if (property.$type) {
if (property && property.$type) {
const childModdleElement = property;

childModdleElement.$parent = moddleElement;
Expand Down
21 changes: 20 additions & 1 deletion test/utils/element.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ describe('utils/element', function() {

describe('allowed', function() {

it('should not return errors', function() {
it('should not return errors (undefined)', function() {

// given
const serviceTask = createElement('bpmn:ServiceTask');
Expand All @@ -473,6 +473,25 @@ describe('utils/element', function() {
});


it('should not return errors (null)', function() {

// given
const serviceTask = createElement('bpmn:ServiceTask', {
modelerTemplate: null
});

// when
const errors = hasProperties(serviceTask, {
modelerTemplate: {
allowed: false
}
});

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


it('should return errors', function() {

// given
Expand Down

0 comments on commit 9d2dcb9

Please sign in to comment.