Skip to content

Commit ee4c226

Browse files
committed
chore: add tests for new features
1 parent 4fd950a commit ee4c226

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/index.spec.tsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,37 @@ test('custom viewProps are working', async () => {
355355
expect(ob).toHaveBeenCalled();
356356
}
357357
});
358+
test('custom buttonsContainerProps are working', async () => {
359+
const kd = jest.fn(() => false);
360+
const of = jest.fn(() => false);
361+
const ob = jest.fn(() => false);
362+
const { container } = render(
363+
<EdiText
364+
value={VALUE}
365+
onSave={() => false}
366+
buttonsContainerProps={{
367+
onKeyDown: kd,
368+
onFocus: of,
369+
onBlur: ob,
370+
className: 'buttons-container',
371+
}}
372+
/>
373+
);
374+
const buttonsContainer = container.querySelector(
375+
'[editext="button-container"]'
376+
);
377+
if (buttonsContainer) {
378+
await waitFor(() => {
379+
fireEvent.focusIn(buttonsContainer);
380+
fireEvent.keyDown(buttonsContainer, { key: 'Enter', code: 'Enter' });
381+
fireEvent.focusOut(buttonsContainer);
382+
});
383+
expect(buttonsContainer).toHaveClass('buttons-container');
384+
expect(kd).toHaveBeenCalled();
385+
expect(of).toHaveBeenCalled();
386+
expect(ob).toHaveBeenCalled();
387+
}
388+
});
358389

359390
test('custom inputProps are working', async () => {
360391
const kd = jest.fn(() => false);

0 commit comments

Comments
 (0)