frontend-app-api: add node map to app graph
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -46,6 +46,7 @@ describe('buildAppGraph', () => {
|
||||
edges: { attachments: new Map() },
|
||||
});
|
||||
expect(Array.from(graph.orphans)).toEqual([]);
|
||||
expect(Array.from(graph.nodes.keys())).toEqual(['core']);
|
||||
});
|
||||
|
||||
it('should create a graph', () => {
|
||||
@@ -62,6 +63,16 @@ describe('buildAppGraph', () => {
|
||||
'b',
|
||||
);
|
||||
|
||||
expect(Array.from(graph.nodes.keys())).toEqual([
|
||||
'a',
|
||||
'b',
|
||||
'c',
|
||||
'bx1',
|
||||
'bx2',
|
||||
'by1',
|
||||
'dx1',
|
||||
]);
|
||||
|
||||
expect(JSON.parse(JSON.stringify(graph.root))).toMatchInlineSnapshot(`
|
||||
{
|
||||
"attachments": {
|
||||
@@ -118,6 +129,16 @@ describe('buildAppGraph', () => {
|
||||
'b',
|
||||
);
|
||||
|
||||
expect(Array.from(graph.nodes.keys())).toEqual([
|
||||
'bx2',
|
||||
'a',
|
||||
'by1',
|
||||
'b',
|
||||
'bx1',
|
||||
'c',
|
||||
'dx1',
|
||||
]);
|
||||
|
||||
expect(String(graph.root)).toMatchInlineSnapshot(`
|
||||
"<b>
|
||||
x [
|
||||
|
||||
@@ -157,5 +157,5 @@ export function buildAppGraph(
|
||||
throw new Error(`No root node with id '${rootNodeId}' found in app graph`);
|
||||
}
|
||||
|
||||
return { root: rootNode, orphans: orphanNodes };
|
||||
return { root: rootNode, nodes, orphans: orphanNodes };
|
||||
}
|
||||
|
||||
@@ -71,5 +71,6 @@ export interface AppNode {
|
||||
|
||||
export interface AppGraph {
|
||||
root: AppNode;
|
||||
nodes: Map<string /* id */, AppNode>;
|
||||
orphans: Iterable<AppNode>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user