Skip to content

Commit 9902814

Browse files
committed
test: add case for empty prefix/suffix
1 parent 011eeed commit 9902814

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/components/__tests__/CurrencyInput-suffix.spec.tsx

+16
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,20 @@ describe('<CurrencyInput/> suffix', () => {
4444

4545
expect(screen.getByRole('textbox')).toHaveValue('$1,234.9 %');
4646
});
47+
48+
it('should handle empty prefix and suffix', () => {
49+
render(
50+
<CurrencyInput onValueChange={onValueChangeSpy} prefix="" suffix="" defaultValue="1234" />
51+
);
52+
53+
expect(screen.getByRole('textbox')).toHaveValue('1,234');
54+
55+
userEvent.type(screen.getByRole('textbox'), '56');
56+
57+
expect(screen.getByRole('textbox')).toHaveValue('123,456');
58+
59+
userEvent.type(screen.getByRole('textbox'), '{backspace}{backspace}');
60+
61+
expect(screen.getByRole('textbox')).toHaveValue('1,234');
62+
});
4763
});

0 commit comments

Comments
 (0)