Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

114
Vistas
Función encadenada Jasmine Testing

Tengo esta clase base llamada UIComponent. Tengo esta llamada en mi código.

 const detailPanel = this.getParent() //PopupBody .getParent() //IComponent .getParent() //TabPanel .getParent() //TabContents .getParent() //TabListControl .getParent() //TabControl .getParent() //DetailPanelComposition .getParent();//DetailPanel

cada uno de los objetos devueltos son clases diferentes que heredan la clase UIComponent. Intenté convertirlo al siguiente código con la esperanza de que fuera fácil convertirlo a la prueba de unidad Jasmine.

 const inputComment = this.getChild("inputComment"); const PopupBody = this.getParent(); const iComponent = PopupBody.getParent(); const tabPanel = iComponent.getParent(); const tabContents = tabPanel.getParent(); const tabListControl = tabContents.getParent(); const tabControl = tabListControl.getParent(); const detailPanelComposition = tabControl.getParent(); const detailPanel = detailPanelComposition.getParent();

Mi problema es que estoy haciendo que funcione en el this.getParent() inicial, pero cualquier llamada getParent() (llamadas encadenadas o no encadenadas) que tenga éxito me da un error.

 TypeError: Cannot read properties of null (reading 'getParent')

entonces la prueba falla desde const iComponent = PopupBody.getParent(); o .getParent() //IComponent. ¿Cuál es la mejor manera de probar esto? A continuación se muestra mi caso de prueba inicial

 describe("The actionComponent.resetComment function", () => { let actionComponent; let PopupBody; let iComponent; let tabPanel; let tabContents; let tabListControl; let tabControl; let detailPanelComposition; let detailPanel; beforeEach(() => { actionComponent = new ActionComponent(); spyOn(actionComponent, "getParent").and.callThrough(); PopupBody = actionComponent.getParent(); }); it("gets the PopupBody parent", () => { expect(actionComponent.getParent).toHaveBeenCalled(); }); });
about 4 years 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 vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda