diff --git a/packages/behavior/context/context.js b/packages/behavior/context/context.js index eae49b3..6dd24b2 100644 --- a/packages/behavior/context/context.js +++ b/packages/behavior/context/context.js @@ -22,7 +22,7 @@ export class Context { static allTypesInvertedDigraph() { const digraph = this.allTypesDigraph(); - const inverted = {}; + let inverted = {}; const fromTypes = Object.keys(digraph); for (let i = 0; i < fromTypes.length; i++) { const fromType = fromTypes[i]; @@ -33,7 +33,12 @@ export class Context { inverted[toType][fromType] = true; } } - return mapObject(inverted, (types) => Object.keys(types)); + inverted = mapObject(inverted, (types) => Object.keys(types)); + inverted = mapObject( + inverted, + (types) => arrayUnique(flatten(types.map((type) => (inverted[type] || []).concat(type)))), + ); + return inverted; } static describe(description, fn) {