-
Notifications
You must be signed in to change notification settings - Fork 594
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(Divider): adjust ts & docs & test
- Loading branch information
Showing
7 changed files
with
44 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,22 @@ | ||
import React from 'react'; | ||
import Enzyme from 'enzyme'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
import Divider from '../index'; | ||
import '../style'; | ||
import { unmount, testReact } from '../../util/__tests__/legacy/a11y/validate'; | ||
import { testReact } from '../../util/__tests__/a11y/validate'; | ||
|
||
Enzyme.configure({ adapter: new Adapter() }); | ||
|
||
/* eslint-disable no-undef, react/jsx-filename-extension */ | ||
describe('Divider A11y', () => { | ||
let wrapper; | ||
|
||
afterEach(() => { | ||
if (wrapper) { | ||
wrapper.unmount(); | ||
wrapper = null; | ||
} | ||
unmount(); | ||
}); | ||
|
||
it('should render', async () => { | ||
wrapper = await testReact(<Divider />); | ||
return wrapper; | ||
await testReact(<Divider />); | ||
}); | ||
|
||
it('should render dashed', async () => { | ||
wrapper = await testReact(<Divider dashed />); | ||
return wrapper; | ||
await testReact(<Divider dashed />); | ||
}); | ||
|
||
it('should render ver', async () => { | ||
wrapper = await testReact(<Divider direction="ver" />); | ||
return wrapper; | ||
await testReact(<Divider direction="ver" />); | ||
}); | ||
|
||
it('should render orientation', async () => { | ||
wrapper = await testReact(<Divider orientation="left">Left Text</Divider>); | ||
return wrapper; | ||
await testReact(<Divider orientation="left">Left Text</Divider>); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,21 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import Enzyme, { mount } from 'enzyme'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
import assert from 'power-assert'; | ||
import Divider from '../index'; | ||
import '../style'; | ||
|
||
Enzyme.configure({ adapter: new Adapter() }); | ||
|
||
const render = element => { | ||
let inc; | ||
const container = document.createElement('div'); | ||
document.body.appendChild(container); | ||
ReactDOM.render(element, container, function () { | ||
inc = this; | ||
}); | ||
return { | ||
setProps: props => { | ||
const clonedElement = React.cloneElement(element, props); | ||
ReactDOM.render(clonedElement, container); | ||
}, | ||
unmount: () => { | ||
ReactDOM.unmountComponentAtNode(container); | ||
document.body.removeChild(container); | ||
}, | ||
instance: () => { | ||
return inc; | ||
}, | ||
find: selector => { | ||
return container.querySelectorAll(selector); | ||
}, | ||
}; | ||
}; | ||
|
||
describe('Divider', () => { | ||
let wrapper; | ||
|
||
beforeEach(() => { | ||
const overlay = document.querySelectorAll('.next-overlay-wrapper'); | ||
overlay.forEach(dom => { | ||
document.body.removeChild(dom); | ||
}); | ||
}); | ||
|
||
afterEach(() => { | ||
if (wrapper) { | ||
wrapper.unmount(); | ||
wrapper = null; | ||
} | ||
}); | ||
|
||
it('should render', () => { | ||
wrapper = render(<Divider />); | ||
assert(document.querySelector('.next-divider')); | ||
cy.mount(<Divider />); | ||
cy.get('.next-divider'); | ||
}); | ||
|
||
it('should render dashed', () => { | ||
wrapper = render(<Divider dashed />); | ||
assert(document.querySelector('.next-divider-dashed')); | ||
cy.mount(<Divider dashed />); | ||
cy.get('.next-divider-dashed'); | ||
}); | ||
|
||
it('should render text right', () => { | ||
wrapper = render(<Divider orientation="right">Right Text</Divider>); | ||
|
||
assert(document.querySelector('.next-divider-with-text-right')); | ||
assert(document.querySelector('.next-divider-inner-text').innerHTML === 'Right Text'); | ||
cy.mount(<Divider orientation="right">Right Text</Divider>); | ||
cy.get('.next-divider-with-text-right'); | ||
cy.get('.next-divider-inner-text').contains('Right Text'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
import { Divider as MeetDivider } from '@alifd/meet-react'; | ||
import NextDivider from '../index'; | ||
|
||
const Divider = MeetDivider ? MeetDivider : NextDivider; | ||
import { Divider } from '@alifd/meet-react'; | ||
|
||
export default Divider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,25 @@ | ||
/// <reference types="react" /> | ||
|
||
import React from 'react'; | ||
import { CommonProps } from '../util'; | ||
|
||
/** | ||
* @api Divider | ||
*/ | ||
export interface DividerProps extends React.HTMLAttributes<HTMLElement>, CommonProps { | ||
/** | ||
* 是否为虚线 | ||
* @en Is it a dashed line | ||
* @defaultValue false | ||
*/ | ||
dashed?: boolean; | ||
/** | ||
* 线是水平还是垂直类型 | ||
* @en Is the line of horizontal or vertical type | ||
* @defaultValue 'hoz' | ||
*/ | ||
direction?: 'hoz' | 'ver'; | ||
/** | ||
* 分割线标题的位置 | ||
* @en The position of the divider title | ||
* @defaultValue 'center' | ||
*/ | ||
orientation?: 'left' | 'right' | 'center'; | ||
} | ||
|
||
export default class Divider extends React.Component<DividerProps, any> {} |