Skip to content

Commit f599d67

Browse files
committed
test: more cloneElement.spec
1 parent 12f9e24 commit f599d67

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module.exports = {
2828
},
2929
rootDir: __dirname,
3030
testMatch: [
31-
// '<rootDir>/packages/nerv/__tests__/event.spec.js',
31+
// '<rootDir>/packages/nerv/__tests__/cloneElement.spec.js',
3232
// '<rootDir>/packages/nerv/__tests__/component.spec.js',
3333
// '<rootDir>/packages/nerv/__tests__/render.spec.js',
3434
// '<rootDir>/packages/nerv/__tests__/lifecycle.spec.js',

packages/nerv/__tests__/cloneElement.spec.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,28 @@ describe('cloneElement()', () => {
99
scratch = document.createElement('div')
1010
})
1111

12+
it('can clone vtext', () => {
13+
const t = cloneElement('test')
14+
expect(t.text).toEqual('test')
15+
})
16+
17+
it('can clone svg', () => {
18+
const t1 = createElement('svg')
19+
render(t1, scratch)
20+
const t2 = cloneElement(t1)
21+
expect(t2.namespace).toBeTruthy()
22+
})
23+
24+
it('can clone fragment', () => {
25+
const f1 = [
26+
<div>1</div>,
27+
<span>2</span>
28+
]
29+
const f2 = cloneElement(f1)
30+
expect(f2[0].children.text).toBe('1')
31+
expect(f2[1].children.text).toBe('2')
32+
})
33+
1234
it('can clone a vnode with props', () => {
1335
const vnode = <div className='hh' style={{ width: '800px' }} />
1436
const cloneVNode = cloneElement(vnode)

0 commit comments

Comments
 (0)