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

fix: ignore null properties #39

Merged
merged 1 commit into from
Aug 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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