Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Calculadora

0

260
Vistas
Jest testing : Get Actual height/width of element which are responsive

I have a requirement where I have created HTML bootstrap modal as responsive based on screen resolution and for that, I have used percentage as a unit while setting height/width like below:

<div id="main-popup" class="modal" style="width:500px;height:450px;'>
  <div class="modal-dialog">
    <div class="modal-header" style="width:100%;height:5%"></div>
    <div class="modal-body" style="width:100%;height:90%">
        <div class="left" style="width:25%"></div>
        <div class="right" style="width:75%">
          <table table-hgight="430">
            ....
          </table>
        </div>
    </div>
    <div class="modal-footer" style="width:100%;height:5%"></div>
  </div>
</div>

To make this above popup responsive, I have added the below code in javascript:

$("#main-popup).css('width', '80%');
$("#main-popup).css('height', '75%');
$("#main-popup table").attr("table-height", $("#main-popup).height() * 0.9);

This works perfectly in the application, but in jest testing when I tried to get the actual height/width of those modal elements it's always returning 0. Not sure what I'm missing here.

7 months ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar empleo Planes Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2023 PeakU Inc. All Rights Reserved.