section.test.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { Form } from '../../index';
  2. import { noop } from 'lodash';
  3. import { BASE_CLASS_PREFIX } from '../../../semi-foundation/base/constants';
  4. const Section = Form.Section;
  5. function getSection(props) {
  6. return mount(<Section {...props}></Section>);
  7. }
  8. describe('Form.Label', () => {
  9. it('className & style', () => {
  10. let props = {
  11. className: 'sec-test',
  12. style: {
  13. color: 'red',
  14. },
  15. };
  16. const section = getSection(props);
  17. expect(section.exists('section.sec-test')).toEqual(true);
  18. expect(section.find('section.sec-test')).toHaveStyle('color', 'red');
  19. });
  20. it('children', () => {
  21. const section = mount(<Form>
  22. <Section>
  23. <Form.Input field='test' className='test'></Form.Input>
  24. </Section>
  25. </Form>)
  26. expect(section.exists(`.test`)).toEqual(true);
  27. });
  28. it('text', () => {
  29. let props = {
  30. text: 'semi',
  31. };
  32. const section = getSection(props);
  33. expect(section.find('.semi-form-section-text').text()).toEqual('semi');
  34. // text = 0
  35. section.setProps({ text: 0 });
  36. section.update();
  37. expect(section.find('.semi-form-section-text').text()).toEqual('0');
  38. let text = <div>{'semi'}</div>;
  39. // text = reactNode
  40. section.setProps({ text: text });
  41. section.update();
  42. expect(section.contains(text)).toEqual(true);
  43. });
  44. });