calculateGutter.test.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import React from 'react';
  2. import { Row, Col } from '../index';
  3. describe('Row', () => {
  4. it('gutter with number calc should be called right', () => {
  5. const wrapper = mount(
  6. <Row gutter={16}>
  7. <Col span={6} />
  8. </Row>
  9. );
  10. const rowNode = wrapper.find('.semi-row').getDOMNode();
  11. const colNode = wrapper.find('.semi-col').getDOMNode();
  12. expect(rowNode.style.marginLeft).toBe('-8px');
  13. expect(rowNode.style.marginRight).toBe('-8px');
  14. expect(colNode.style.paddingLeft).toBe('8px');
  15. expect(colNode.style.paddingRight).toBe('8px');
  16. });
  17. it('gutter with object calc should be called right', () => {
  18. const wrapper = mount(
  19. <Row gutter={{ xs: 16, sm: 16, md: 16 }}>
  20. <Col span={6} />
  21. </Row>
  22. );
  23. const rowNode = wrapper.find('.semi-row').getDOMNode();
  24. const colNode = wrapper.find('.semi-col').getDOMNode();
  25. expect(rowNode.style.marginLeft).toBe('-8px');
  26. expect(rowNode.style.marginRight).toBe('-8px');
  27. expect(colNode.style.paddingLeft).toBe('8px');
  28. expect(colNode.style.paddingRight).toBe('8px');
  29. });
  30. it('gutter with array calc should be called right', () => {
  31. const wrapper = mount(
  32. <Row gutter={[{ xs: 16, sm: 16, md: 16 }, 16]}>
  33. <Col span={6} />
  34. </Row>
  35. );
  36. const rowNode = wrapper.find('.semi-row').getDOMNode();
  37. const colNode = wrapper.find('.semi-col').getDOMNode();
  38. expect(rowNode.style.marginLeft).toBe('-8px');
  39. expect(rowNode.style.marginRight).toBe('-8px');
  40. expect(rowNode.style.marginTop).toBe('-8px');
  41. expect(rowNode.style.marginBottom).toBe('-8px');
  42. expect(colNode.style.paddingLeft).toBe('8px');
  43. expect(colNode.style.paddingRight).toBe('8px');
  44. expect(colNode.style.paddingTop).toBe('8px');
  45. expect(colNode.style.paddingBottom).toBe('8px');
  46. });
  47. });