diff --git a/lib/features/search/BpmnSearchProvider.js b/lib/features/search/BpmnSearchProvider.js index efb0a161d..1d535bcfa 100644 --- a/lib/features/search/BpmnSearchProvider.js +++ b/lib/features/search/BpmnSearchProvider.js @@ -146,12 +146,12 @@ function compareTokens(tokensA, tokensB) { /** * Compares two strings. * - * @param {string} a - * @param {string} b + * @param {string} [a] + * @param {string} [b] * * @returns {number} */ -function compareStrings(a, b) { +function compareStrings(a = '', b = '') { return a.localeCompare(b); } diff --git a/test/spec/features/search/BpmnSearchProviderSpec.js b/test/spec/features/search/BpmnSearchProviderSpec.js index 02a3fe397..8ce04cbf9 100644 --- a/test/spec/features/search/BpmnSearchProviderSpec.js +++ b/test/spec/features/search/BpmnSearchProviderSpec.js @@ -206,6 +206,21 @@ describe('features - BPMN search provider', function() { expect(elements[5].element.id).to.eql('foo_1'); })); + + it('should handle elements without label', inject(function(bpmnSearch) { + + // given + var pattern = 'ass'; + + // when + var elements = bpmnSearch.find(pattern); + + // then + expect(elements).length(2); + expect(elements[0].element.id).to.eql('Association_1'); + expect(elements[1].element.id).to.eql('Association_2'); + })); + }); }); diff --git a/test/spec/features/search/bpmn-search-sorting.bpmn b/test/spec/features/search/bpmn-search-sorting.bpmn index 1fcf91c26..c4d8a9203 100644 --- a/test/spec/features/search/bpmn-search-sorting.bpmn +++ b/test/spec/features/search/bpmn-search-sorting.bpmn @@ -1,5 +1,5 @@ - + @@ -7,33 +7,51 @@ + + + + - + - + - + - + - + - + + + + + + + + + + + + + + +