brucou / kingly

Zero-cost state-machine library for robust, testable and portable user interfaces (most machines compile ~1-2KB)

Home Page:https://brucou.github.io/documentation/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Erroneous aggregation of machine outputs when graph has deep hierarchy

brucou opened this issue · comments

While testing for integration with the yed graph editor:

  • yed graph: Imgur
    const outputs1 = [
      { event1: { n: 0 } },
      { event1: void 0 },
      { event1: void 0 },
      { event2: { shouldReturnToA: false } },
      { event2: { shouldReturnToA: false } },
    ].map(createStateMachine(fsmDef, settings));

      assert.deepEqual(outputs1, [
        ["A -> Group1", "Group1 -> B", null, "Group2 -> Group3", "Group3 -> B"],
        [null, null],
        ["A -> B"],
        ["B -> D", null],
        [null]
      ], `Branch machine initialized with number ok`);

fails. Instead a [null] value is observed in the aggregated outputs:

     [
        ["A -> Group1", "Group1 -> B", [null], "Group2 -> Group3", "Group3 -> B"],
        [[null], [null]],
        ["A -> B"],
        ["B -> D", [null]],
        [null]
      ], `Branch machine initialized with number ok`);

,,, actually the bug is with the object diff formatting of mocha. null is presented as [null]....