Skip to content

Commit

Permalink
test(18214): fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vanch3d committed Dec 13, 2023
1 parent 31bb860 commit 41d3174
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'vitest'
import { act, renderHook } from '@testing-library/react'
import { NodeAddChange, EdgeAddChange, Node, Edge } from 'reactflow'
import { NodeAddChange, EdgeAddChange, Node, Edge, Rect } from 'reactflow'

import { Group, IdStubs, NodeTypes, WorkspaceAction, WorkspaceState } from '../types.ts'
import useWorkspaceStore from './useWorkspaceStore.ts'
Expand Down Expand Up @@ -82,10 +82,11 @@ describe('useWorkspaceStore', () => {
position: { x: 0, y: 0 },
data: { childrenNodeIds: ['idAdapter', 'idBridge'], title: 'my title', isOpen: true },
}
const rect: Rect = { x: 0, y: 0, width: 250, height: 250 }

const groupEdge: Edge = { id: '1-233', source: '1', target: IdStubs.EDGE_NODE }

onInsertGroupNode(group, groupEdge)
onInsertGroupNode(group, groupEdge, rect)
})

expect(result.current.nodes).toHaveLength(4)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { expect } from 'vitest'
import { getGroupLayout } from './group.utils.ts'
import { Rect } from 'reactflow'
import { MOCK_NODE_ADAPTER } from '@/__test-utils__/react-flow/nodes.ts'

describe('getGroupLayout', () => {
it('should return the layout characteristics of a group', async () => {
expect(
getGroupLayout([{ ...MOCK_NODE_ADAPTER, position: { x: 0, y: 0 }, width: 50, height: 100 }])
).toStrictEqual<Rect>({
height: 164,
width: 90,
x: -20,
y: -44,
})
})
})

0 comments on commit 41d3174

Please sign in to comment.