diff --git a/tests/test_mermaid.py b/tests/test_mermaid.py index 589a1003..437bcb85 100644 --- a/tests/test_mermaid.py +++ b/tests/test_mermaid.py @@ -239,6 +239,26 @@ def test_roi_parallel_deeper(self): self.assertEqual(len(edges), 2) self.assertEqual(len(nodes), 10) + def test_transitions_without_labels_between_outer_states(self): + states = [ + 'A', 'B', + {'name': 'C', + 'parallel': [ + {'name': '1', 'children': ['a', {'name': 'b', 'final': True}], + 'initial': 'a', 'transitions': [['go', 'a', 'b']]}, + {'name': '2', 'children': ['a', {'name': 'b', 'final': True}], + 'initial': 'a', 'transitions': [['go', 'a', 'b']]} + ]} + ] + transitions = [['', 'C', 'A'], ['', 'A', 'B'], ['', 'B', 'C']] + machine = self.machine_cls(states=states, transitions=transitions, initial='A', + graph_engine=self.graph_engine) + dot = machine.get_graph().source + + self.assertIn('C --> A', dot) + self.assertIn('A --> B', dot) + self.assertIn('B --> C', dot) + class TestDiagramsLockedNested(TestDiagramsNested): diff --git a/transitions/extensions/diagrams_mermaid.py b/transitions/extensions/diagrams_mermaid.py index 9df99ad3..9d2a00d9 100644 --- a/transitions/extensions/diagrams_mermaid.py +++ b/transitions/extensions/diagrams_mermaid.py @@ -214,9 +214,10 @@ def _add_edges(self, transitions, container): for src, dests in edges_attr.items(): for dst, attr in dests.items(): - if not attr["label"]: - continue - container.append("{source} --> {dest}: {label}".format(**attr)) + if attr["label"]: + container.append("{source} --> {dest}: {label}".format(**attr)) + else: + container.append("{source} --> {dest}".format(**attr)) def _create_edge_attr(self, src, dst, transition): return {"source": src, "dest": dst, "label": self._transition_label(transition)}