Skip to content

Commit 9065d44

Browse files
committed
added more test for Select component
1 parent c45d5c5 commit 9065d44

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/components/select/__tests__/Select.test.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,20 @@ describe(`Select`, () => {
1717
<Select onClick={handleClick} selectRef={ref} />
1818
);
1919
};
20-
it(`should do nothing if ref does not exist`, () => {
20+
21+
it(`should do nothing if ref does not Exist`, () => {
2122
const useRefSpy = jest.spyOn(React, 'useRef').mockReturnValueOnce({ current: null });
2223
const component = shallow(<SelectComp />);
2324
component.find('Select').simulate('click');
2425
expect(useRefSpy).toBeCalledWith(null);
2526
});
27+
28+
it('should handle DOM events where ref Exists', () => {
29+
const useRefSpy = jest.spyOn(React, 'useRef').mockReturnValueOnce({ current: document.createElement('select') });
30+
const mock = jest.fn();
31+
const component = shallow(<SelectComp onHandle={mock} />);
32+
component.find('Select').simulate('click');
33+
expect(useRefSpy).toBeCalledWith(null);
34+
expect(mock).toBeCalledTimes(1);
35+
});
2636
})

0 commit comments

Comments
 (0)