Skip to content

Commit 2bb1b58

Browse files
feat: add tests to modalSize
1 parent 19e4aaa commit 2bb1b58

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

packages/field-plugin/src/createFieldPlugin/createPluginActions/createPluginActions.test.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,44 @@ describe('createPluginActions', () => {
138138
} satisfies Partial<ModalChangeMessage>),
139139
)
140140
})
141+
it('sends modalSize to the container when opening the modal', () => {
142+
const { uid, postToContainer, onUpdateState } = mock()
143+
const {
144+
actions: { setModalOpen },
145+
} = createPluginActions({
146+
uid,
147+
postToContainer,
148+
onUpdateState,
149+
validateContent,
150+
})
151+
152+
setModalOpen(true, { width: '50%' })
153+
expect(postToContainer).toHaveBeenCalledWith(
154+
expect.objectContaining({
155+
event: 'toggleModal',
156+
status: true,
157+
modalSize: { width: '50%' },
158+
} satisfies Partial<ModalChangeMessage>),
159+
)
160+
161+
setModalOpen(true, { height: '50%' })
162+
expect(postToContainer).toHaveBeenCalledWith(
163+
expect.objectContaining({
164+
event: 'toggleModal',
165+
status: true,
166+
modalSize: { height: '50%' },
167+
} satisfies Partial<ModalChangeMessage>),
168+
)
169+
170+
setModalOpen(true, { width: '50%', height: '50%' })
171+
expect(postToContainer).toHaveBeenCalledWith(
172+
expect.objectContaining({
173+
event: 'toggleModal',
174+
status: true,
175+
modalSize: { width: '50%', height: '50%' },
176+
} satisfies Partial<ModalChangeMessage>),
177+
)
178+
})
141179
})
142180
describe('value state change', () => {
143181
it('updates the value state when setContent is called', () => {

0 commit comments

Comments
 (0)