Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

325
Views
¿Cómo probar addEventListener la función use jest y testing-library/vue?

Intenté probar esta función pero no la cubrí por completo. No estoy seguro de cómo puedo probarlo cuando uso addEventListener para escuchar el evento de desplazamiento

 import _ from 'lodash' const outlineScroll = (arg: any) => { const currentMode = arg.currentMode let headingEles = getHeadings(arg) // this is array [element.offsetTop] let ele = arg.preview.element.style.display === 'none' ? arg[currentMode].element : arg.preview.element const vditorOutline = arg.outline.element let outline = arg.outline.element.querySelectorAll('.vditor-outline__content li span[data-target-id]') let top = ele.scrollTop + 35 outline.forEach((item, i) => { item.className = '' if ( top >= headingEles[i] && top < headingEles[i+1]) { item.className = 'vditor-content__active' } else if (top >= headingEles[headingEles.length - 1]) { outline[headingEles.length - 1].className = 'vditor-content__active' } if (item.className.includes('vditor-content__active')) { if (item.offsetTop > (vditorOutline.clientHeight/10 * 9)) { vditorOutline.scrollTo({ left: 0, top: item.offsetTop - vditorOutline.clientHeight / 2, behavior: "smooth" }) } else if (item.offsetTop < vditorOutline.clientHeight) { vditorOutline.scrollTo({ left: 0, top: 0, behavior: "smooth" }) } } }) } let throttle = _.throttle(outlineScroll, 300, {leading: false, trailing: true}) window.addEventListener('scroll', throttle, true)

y los argumentos de la función son objetos como este:

 { currentMode: 'ir', preview:{ element: '' // the value is a HTMLElement }, outline:{ element: '' // the value is a HTMLElement }, ir: { element: '' // the value is a HTMLElement } }

entonces, cómo esperar el contorno.forEach item.className y vditorOutline.scrollTo , no tengo ninguna idea

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!