|
| 1 | +/** |
| 2 | + * @jest-environment jsdom |
| 3 | + */ |
| 4 | +import { render, screen } from '@testing-library/react'; |
| 5 | +import '@testing-library/jest-dom'; |
| 6 | +import React from 'react'; |
| 7 | +import Split from '../src'; |
| 8 | + |
| 9 | +test('renders react-split', () => { |
| 10 | + render( |
| 11 | + <Split mode="vertical" data-testid="split" visiable={false}> |
| 12 | + <div style={{ minHeight: 45, background: '#dcdcdc' }}> |
| 13 | + Header |
| 14 | + </div> |
| 15 | + <Split visiable={false}> |
| 16 | + <div style={{ minWidth: 200, maxWidth: 200, minHeight: 120, background: '#b5b5b5' }}> |
| 17 | + Sider |
| 18 | + </div> |
| 19 | + <div style={{ width: '100%', background: '#ececec' }}> |
| 20 | + Content |
| 21 | + </div> |
| 22 | + </Split> |
| 23 | + <div style={{ minHeight: 45, background: '#dcdcdc' }}> |
| 24 | + Footer |
| 25 | + </div> |
| 26 | + </Split> |
| 27 | + ); |
| 28 | + const element = screen.getByTestId('split'); |
| 29 | + expect(element.className).toEqual('w-split w-split-vertical') |
| 30 | + expect(element).toBeInTheDocument(); |
| 31 | +}); |
| 32 | + |
| 33 | +test('lineBar props', () => { |
| 34 | + render( |
| 35 | + <Split mode="vertical" lineBar data-testid="split" visiable={false}> |
| 36 | + <div style={{ minHeight: 45, background: '#dcdcdc' }}> |
| 37 | + Header |
| 38 | + </div> |
| 39 | + </Split> |
| 40 | + ); |
| 41 | + const element = screen.getByTestId('split'); |
| 42 | + expect(element.className).toEqual('w-split w-split-vertical') |
| 43 | + expect(element.childNodes.length).toEqual(1); |
| 44 | + expect(element).toBeInTheDocument(); |
| 45 | +}); |
| 46 | + |
| 47 | +test('disable props', () => { |
| 48 | + render( |
| 49 | + <Split disable data-testid="split"> |
| 50 | + <div> Header </div> |
| 51 | + <div> Header </div> |
| 52 | + </Split> |
| 53 | + ); |
| 54 | + const element = screen.getByTestId('split'); |
| 55 | + expect(element.className).toEqual('w-split w-split-horizontal'); |
| 56 | + expect((element.childNodes[1] as any).className).toEqual('w-split-bar w-split-large-bar disable'); |
| 57 | + expect(element.childNodes.length).toEqual(3); |
| 58 | + expect(element).toBeInTheDocument(); |
| 59 | +}); |
0 commit comments