Skip to content

Commit

Permalink
fix: add onChange to onBlur test
Browse files Browse the repository at this point in the history
  • Loading branch information
cchanxzy committed Nov 4, 2020
1 parent 501de54 commit 4195ef6
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/components/__tests__/CurrencyInput-onBlurValue.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,31 @@ const name = 'inputName';

describe('<CurrencyInput /> component > onBlurValue', () => {
const onBlurValueSpy = jest.fn();
const onChangeSpy = jest.fn();

beforeEach(() => {
jest.clearAllMocks();
});

it('should call onBlurValue and onChange', () => {
const view = shallow(
<CurrencyInput
id={id}
name={name}
prefix="$"
onBlurValue={onBlurValueSpy}
onChange={onChangeSpy}
precision={2}
/>
);
view.find(`#${id}`).simulate('blur', { target: { value: '123' } });
expect(onBlurValueSpy).toBeCalledWith('123.00', name);
expect(onChangeSpy).toBeCalledWith('123.00', name);

const updatedView = view.update();
expect(updatedView.find(`#${id}`).prop('value')).toBe('$123.00');
});

it('should call onBlurValue for 0', () => {
const view = shallow(
<CurrencyInput id={id} name={name} prefix="$" onBlurValue={onBlurValueSpy} />
Expand Down

0 comments on commit 4195ef6

Please sign in to comment.