props.js 925 B

1234567891011121314151617181920212223242526
  1. import { basePatch as patch } from 'web/runtime/patch'
  2. import VNode from 'core/vdom/vnode'
  3. describe('props module', () => {
  4. it('should create an element with props', () => {
  5. const vnode = new VNode('a', { props: { src: 'http://localhost/' }})
  6. const elm = patch(null, vnode)
  7. expect(elm.src).toBe('http://localhost/')
  8. })
  9. it('should change the elements props', () => {
  10. const vnode1 = new VNode('a', { props: { src: 'http://localhost/' }})
  11. const vnode2 = new VNode('a', { props: { src: 'http://vuejs.org/' }})
  12. patch(null, vnode1)
  13. const elm = patch(vnode1, vnode2)
  14. expect(elm.src).toBe('http://vuejs.org/')
  15. })
  16. it('should remove the elements props', () => {
  17. const vnode1 = new VNode('a', { props: { src: 'http://localhost/' }})
  18. const vnode2 = new VNode('a', { props: {}})
  19. patch(null, vnode1)
  20. const elm = patch(vnode1, vnode2)
  21. expect(elm.src).toBeUndefined()
  22. })
  23. })