import Tip from '../'

it('test Tip default porps', () => {
  const vm = shallow({
    render(h) {
      return (
        <Tip>
          tip
          <Tip.Context>
            tipContext
          </Tip.Context>
        </Tip>
      )
    }
  })
  expect(vm.pos).toBe('down')
  expect(vm.event).toBe('mouseenter')
})

it('test Tip props set `pos`=right and mouse event', async() => {
  const vm = shallow({
    render(h) {
      return (
        <Tip pos="right">
          tip
          <Tip.Context>
            tipContext
          </Tip.Context>
        </Tip>
      )
    }
  })
  expect(vm.pos).toBe('right')
  //when mouse enters
  const eventEnter = document.createEvent('HTMLEvents')
  eventEnter.initEvent('mouseenter', true, false)
  vm.$el.dispatchEvent(eventEnter)
  //tipContext should show up
  const tipContext2 = document.querySelector('#tipContext2')
  expect(getComputedStyle(tipContext2)._values.display).toBe('block')
  await new Promise((done) => {
    setTimeout(() => {
      done()
    }, 50)
  })
  expect(getComputedStyle(tipContext2)._values.opacity).toBe('1')
  //when mouse leaves
  const eventLeave = document.createEvent('HTMLEvents')
  eventLeave.initEvent('mouseleave', true, false)
  vm.$el.dispatchEvent(eventLeave)
  //tipContext should disappear
  expect(document.querySelector('#tipContext2')).toBe(null)
})

it('test Tip props set `pos`=left', () => {
  const vm = shallow({
    render(h) {
      return (
        <Tip pos="left">
          tip
          <Tip.Context>
            tipContext
          </Tip.Context>
        </Tip>
      )
    }
  })
  expect(vm.pos).toBe('left')

  const eventEnter = document.createEvent('HTMLEvents')
  eventEnter.initEvent('mouseenter', true, false)
  vm.$el.dispatchEvent(eventEnter)
})

it('test Tip props set `pos`=up', () => {
  const vm = shallow({
    render(h) {
      return (
        <Tip pos="up">
          tip
          <Tip.Context>
            tipContext
          </Tip.Context>
        </Tip>
      )
    }
  })
  expect(vm.pos).toBe('up')

  const eventEnter = document.createEvent('HTMLEvents')
  eventEnter.initEvent('mouseenter', true, false)
  vm.$el.dispatchEvent(eventEnter)
})

it('test Tip props set `pos`=down', () => {
  const vm = shallow({
    render(h) {
      return (
        <Tip pos="down">
          tip
          <Tip.Context>
            tipContext
          </Tip.Context>
        </Tip>
      )
    }
  })
  expect(vm.pos).toBe('down')

  const eventEnter = document.createEvent('HTMLEvents')
  eventEnter.initEvent('mouseenter', true, false)
  vm.$el.dispatchEvent(eventEnter)
})

@@ -326,38 +326,8 @@
 est 
-Tip props set %60pos%60=right and 
 mous
@@ -341,32 +341,32 @@
 ', async() =%3E %7B%0A
+
   const vm = sha
@@ -419,20 +419,8 @@
 %3CTip
- pos=%22right%22
 %3E%0A  
@@ -541,38 +541,8 @@
  %7D)%0A
-  expect(vm.pos).toBe('right')
 %0A  /
@@ -1267,24 +1267,446 @@
 e(null)%0A%7D)%0A%0A
+it('test Tip props set %60pos%60=right', () =%3E %7B%0A  const vm = shallow(%7B%0A    render(h) %7B%0A      return (%0A        %3CTip pos=%22right%22%3E%0A          tip%0A          %3CTip.Context%3E%0A            tipContext%0A          %3C/Tip.Context%3E%0A        %3C/Tip%3E%0A      )%0A    %7D%0A  %7D)%0A  expect(vm.pos).toBe('right')%0A%0A  const eventEnter = document.createEvent('HTMLEvents')%0A  eventEnter.initEvent('mouseenter', true, false)%0A  vm.$el.dispatchEvent(eventEnter)%0A%7D)%0A%0A
 it('test Tip

split test cases