Skip to content

Commit

Permalink
test: more cloneElement.spec
Browse files Browse the repository at this point in the history
  • Loading branch information
yuche committed Jan 8, 2018
1 parent 12f9e24 commit f599d67
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = {
},
rootDir: __dirname,
testMatch: [
// '<rootDir>/packages/nerv/__tests__/event.spec.js',
// '<rootDir>/packages/nerv/__tests__/cloneElement.spec.js',
// '<rootDir>/packages/nerv/__tests__/component.spec.js',
// '<rootDir>/packages/nerv/__tests__/render.spec.js',
// '<rootDir>/packages/nerv/__tests__/lifecycle.spec.js',
Expand Down
22 changes: 22 additions & 0 deletions packages/nerv/__tests__/cloneElement.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,28 @@ describe('cloneElement()', () => {
scratch = document.createElement('div')
})

it('can clone vtext', () => {
const t = cloneElement('test')
expect(t.text).toEqual('test')
})

it('can clone svg', () => {
const t1 = createElement('svg')
render(t1, scratch)
const t2 = cloneElement(t1)
expect(t2.namespace).toBeTruthy()
})

it('can clone fragment', () => {
const f1 = [
<div>1</div>,
<span>2</span>
]
const f2 = cloneElement(f1)
expect(f2[0].children.text).toBe('1')
expect(f2[1].children.text).toBe('2')
})

it('can clone a vnode with props', () => {
const vnode = <div className='hh' style={{ width: '800px' }} />
const cloneVNode = cloneElement(vnode)
Expand Down

0 comments on commit f599d67

Please sign in to comment.