|
@@ -265,6 +265,56 @@ describe('vnode', () => {
|
|
|
setCurrentRenderingInstance(null)
|
|
setCurrentRenderingInstance(null)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ test('cloneVNode class normalization', () => {
|
|
|
|
|
+ const vnode = createVNode('div')
|
|
|
|
|
+ const expectedProps = {
|
|
|
|
|
+ class: 'a b'
|
|
|
|
|
+ }
|
|
|
|
|
+ expect(cloneVNode(vnode, { class: 'a b' }).props).toMatchObject(
|
|
|
|
|
+ expectedProps
|
|
|
|
|
+ )
|
|
|
|
|
+ expect(cloneVNode(vnode, { class: ['a', 'b'] }).props).toMatchObject(
|
|
|
|
|
+ expectedProps
|
|
|
|
|
+ )
|
|
|
|
|
+ expect(
|
|
|
|
|
+ cloneVNode(vnode, { class: { a: true, b: true } }).props
|
|
|
|
|
+ ).toMatchObject(expectedProps)
|
|
|
|
|
+ expect(
|
|
|
|
|
+ cloneVNode(vnode, { class: [{ a: true, b: true }] }).props
|
|
|
|
|
+ ).toMatchObject(expectedProps)
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ test('cloneVNode style normalization', () => {
|
|
|
|
|
+ const vnode = createVNode('div')
|
|
|
|
|
+ const expectedProps = {
|
|
|
|
|
+ style: {
|
|
|
|
|
+ color: 'blue',
|
|
|
|
|
+ width: '300px'
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ expect(
|
|
|
|
|
+ cloneVNode(vnode, { style: 'color: blue; width: 300px;' }).props
|
|
|
|
|
+ ).toMatchObject(expectedProps)
|
|
|
|
|
+ expect(
|
|
|
|
|
+ cloneVNode(vnode, {
|
|
|
|
|
+ style: {
|
|
|
|
|
+ color: 'blue',
|
|
|
|
|
+ width: '300px'
|
|
|
|
|
+ }
|
|
|
|
|
+ }).props
|
|
|
|
|
+ ).toMatchObject(expectedProps)
|
|
|
|
|
+ expect(
|
|
|
|
|
+ cloneVNode(vnode, {
|
|
|
|
|
+ style: [
|
|
|
|
|
+ {
|
|
|
|
|
+ color: 'blue',
|
|
|
|
|
+ width: '300px'
|
|
|
|
|
+ }
|
|
|
|
|
+ ]
|
|
|
|
|
+ }).props
|
|
|
|
|
+ ).toMatchObject(expectedProps)
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
describe('mergeProps', () => {
|
|
describe('mergeProps', () => {
|
|
|
test('class', () => {
|
|
test('class', () => {
|
|
|
let props1: Data = { class: 'c' }
|
|
let props1: Data = { class: 'c' }
|