fix: fix the tests and creation of nodes.
ref: N25B-408
This commit is contained in:
@@ -23,17 +23,19 @@ import { UndoRedo } from "./EditorUndoRedo.ts";
|
|||||||
* @param deletable - Optional flag to indicate if the node can be deleted (can be deleted by default).
|
* @param deletable - Optional flag to indicate if the node can be deleted (can be deleted by default).
|
||||||
* @returns A fully initialized Node object ready to be added to the flow.
|
* @returns A fully initialized Node object ready to be added to the flow.
|
||||||
*/
|
*/
|
||||||
function createNode(id: string, type: string, position: XYPosition, data: Record<string, unknown>, deletable? : boolean) {
|
function createNode(id: string, type: string, position: XYPosition, data: Record<string, unknown>, deletable?: boolean) {
|
||||||
const defaultData = NodeDefaults[type as keyof typeof NodeDefaults]
|
const defaultData = NodeDefaults[type as keyof typeof NodeDefaults]
|
||||||
const newData = {
|
return {
|
||||||
id: id,
|
id,
|
||||||
type: type,
|
type,
|
||||||
position: position,
|
position,
|
||||||
data: data,
|
deletable,
|
||||||
deletable: deletable,
|
data: {
|
||||||
|
...defaultData,
|
||||||
|
...data,
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return {...defaultData, ...newData}
|
|
||||||
}
|
|
||||||
|
|
||||||
//* Initial nodes, created by using createNode. */
|
//* Initial nodes, created by using createNode. */
|
||||||
const initialNodes : Node[] = [
|
const initialNodes : Node[] = [
|
||||||
|
|||||||
@@ -15,14 +15,16 @@ describe('NormNode', () => {
|
|||||||
|
|
||||||
function createNode(id: string, type: string, position: XYPosition, data: Record<string, unknown>, deletable?: boolean) {
|
function createNode(id: string, type: string, position: XYPosition, data: Record<string, unknown>, deletable?: boolean) {
|
||||||
const defaultData = NodeDefaults[type as keyof typeof NodeDefaults]
|
const defaultData = NodeDefaults[type as keyof typeof NodeDefaults]
|
||||||
const newData = {
|
return {
|
||||||
id: id,
|
id,
|
||||||
type: type,
|
type,
|
||||||
position: position,
|
position,
|
||||||
data: data,
|
deletable,
|
||||||
deletable: deletable,
|
data: {
|
||||||
|
...defaultData,
|
||||||
|
...data,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
return {...defaultData, ...newData}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user