nodeOps.spec.ts 949 B

12345678910111213141516171819202122232425262728
  1. import { nodeOps } from '../src/nodeOps'
  2. describe('runtime-dom: node-ops', () => {
  3. test('the _value property should be cloned', () => {
  4. const el = nodeOps.createElement('input') as HTMLDivElement & {
  5. _value: any
  6. }
  7. el._value = 1
  8. const cloned = nodeOps.cloneNode!(el) as HTMLDivElement & { _value: any }
  9. expect(cloned._value).toBe(1)
  10. })
  11. test("the <select>'s multiple attr should be set in createElement", () => {
  12. const el = nodeOps.createElement('select', false, undefined, {
  13. multiple: ''
  14. }) as HTMLSelectElement
  15. const option1 = nodeOps.createElement('option') as HTMLOptionElement
  16. const option2 = nodeOps.createElement('option') as HTMLOptionElement
  17. option1.selected = true
  18. option2.selected = true
  19. nodeOps.insert(option1, el)
  20. nodeOps.insert(option2, el)
  21. expect(el.multiple).toBe(true)
  22. expect(option1.selected).toBe(true)
  23. expect(option2.selected).toBe(true)
  24. })
  25. })