Skip to content

Commit

Permalink
test(roundtrip): verify local namespaces are kept
Browse files Browse the repository at this point in the history
This adds a test that verifies that locally re-declared namespaces are
kept (to keep diagram changes to a minimum).

Related to bpmn-io/bpmn-js#1310
  • Loading branch information
nikku committed Apr 14, 2020
1 parent 333eaf1 commit 0c4b91c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
10 changes: 10 additions & 0 deletions test/fixtures/bpmn/namespace-redefinition.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" id="Definitions" targetNamespace="http://bpmn.io">
<process id="Process_1">
<dataObjectReference xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" id="DataObjectReference_1" />
<foo:userTask xmlns:foo="http://www.omg.org/spec/BPMN/20100524/MODEL" id="Task_1" name="Task 1" />
</process>
<BPMNDiagram xmlns="http://www.omg.org/spec/BPMN/20100524/DI" id="BPMNDiagram_1">
<BPMNPlane xmlns="http://www.omg.org/spec/BPMN/20100524/DI" bpmnElement="Definitions" />
</BPMNDiagram>
</definitions>
25 changes: 24 additions & 1 deletion test/spec/xml/roundtrip.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import {
validate
} from '../../xml-helper';

import {
readFileSync as readFile
} from 'fs';


describe('bpmn-moddle - roundtrip', function() {

Expand Down Expand Up @@ -591,12 +595,31 @@ describe('bpmn-moddle - roundtrip', function() {

// local namespace declaration is exported
expect(xml).to.contain(
'<BPMNDiagram id="BPMNDiagram_1" xmlns="http://www.omg.org/spec/BPMN/20100524/DI">'
'<BPMNDiagram xmlns="http://www.omg.org/spec/BPMN/20100524/DI" id="BPMNDiagram_1">'
);

await validate(xml);
});


it('local namespace exports', async function() {

// given
var expectedXML = readFile('test/fixtures/bpmn/namespace-redefinition.bpmn', 'utf8');

var {
rootElement
} = await fromFile('test/fixtures/bpmn/namespace-redefinition.bpmn');

// when
var {
xml
} = await toXML(rootElement, { format: true });

// then
expect(xml).to.eql(expectedXML);
});

});


Expand Down

0 comments on commit 0c4b91c

Please sign in to comment.