fix(tests) adjusted FlowConfig type

This commit is contained in:
Peter
2023-11-16 11:18:11 +01:00
parent 14caf422c3
commit 99c24f86c6
4 changed files with 14 additions and 14 deletions
+5 -5
View File
@@ -2,10 +2,10 @@ import { BackgroundProps, ControlProps, Edge, MiniMapProps, Node, PanelProps, Re
declare global {
interface FlowConfig {
flowProps: Omit<ReactFlowProps, 'nodes' | 'edges'> & { nodes: Node[]; edges: Edge[] };
panelProps: PanelProps;
backgroundProps: BackgroundProps;
controlsProps: ControlProps;
minimapProps: MiniMapProps;
flowProps?: Omit<ReactFlowProps, 'nodes' | 'edges'> & { nodes: Node[]; edges: Edge[] };
panelProps?: PanelProps;
backgroundProps?: BackgroundProps;
controlsProps?: ControlProps;
minimapProps?: MiniMapProps;
}
}
+2 -2
View File
@@ -18,8 +18,8 @@ type FlowProps = {
};
export default ({ flowConfig }: FlowProps) => {
const [nodes, setNodes] = useState(flowConfig.flowProps.nodes);
const [edges, setEdges] = useState(flowConfig.flowProps.edges);
const [nodes, setNodes] = useState(flowConfig.flowProps?.nodes);
const [edges, setEdges] = useState(flowConfig.flowProps?.edges);
const props = { ...flowConfig.flowProps, nodes, edges };
const onNodesChange: OnNodesChange = useCallback((changes) => setNodes((nds) => applyNodeChanges(changes, nds)), []);
+5 -5
View File
@@ -20,11 +20,11 @@ declare global {
}
interface FlowConfig {
flowProps: Omit<SvelteFlowProps, 'nodes' | 'edges'> & { nodes: Node[]; edges: Edge[] };
panelProps: PanelProps;
backgroundProps: BackgroundProps;
controlsProps: ControlsProps;
minimapProps: MiniMapProps;
flowProps?: Omit<SvelteFlowProps, 'nodes' | 'edges'> & { nodes: Node[]; edges: Edge[] };
panelProps?: PanelProps;
backgroundProps?: BackgroundProps;
controlsProps?: ControlsProps;
minimapProps?: MiniMapProps;
}
}
@@ -7,8 +7,8 @@
export let flowConfig: FlowConfig;
// Create writables here so it is easier to create test cases
const nodes = writable(flowConfig.flowProps.nodes);
const edges = writable(flowConfig.flowProps.edges);
const nodes = writable(flowConfig.flowProps?.nodes);
const edges = writable(flowConfig.flowProps?.edges);
const flowProps = { ...flowConfig.flowProps, nodes, edges };
</script>