github.com/thanos-io/thanos@v0.32.5/pkg/ui/react-app/src/components/ToggleMoreLess.test.tsx (about) 1 import React from 'react'; 2 import { shallow } from 'enzyme'; 3 import { Button } from 'reactstrap'; 4 import { ToggleMoreLess } from './ToggleMoreLess'; 5 6 describe('ToggleMoreLess', () => { 7 const showMoreValue = false; 8 const defaultProps = { 9 event: (): void => { 10 tggleBtn.setProps({ showMore: !showMoreValue }); 11 }, 12 showMore: showMoreValue, 13 }; 14 const tggleBtn = shallow(<ToggleMoreLess {...defaultProps} />); 15 16 it('renders a show more btn at start', () => { 17 const btn = tggleBtn.find(Button); 18 expect(btn).toHaveLength(1); 19 expect(btn.prop('color')).toEqual('primary'); 20 expect(btn.prop('size')).toEqual('xs'); 21 expect(btn.render().text()).toEqual('show more'); 22 }); 23 24 it('renders a show less btn if clicked', () => { 25 tggleBtn.find(Button).simulate('click'); 26 expect(tggleBtn.find(Button).render().text()).toEqual('show less'); 27 }); 28 });