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

90
Vistas
How to check that document.location.assign was called with specific url

I'm testing with jest function what called document.location.assign url with params.

sort: function (type){
  document.location.assign(document.location.pathname + '?' + `&order=${type}-asc`);
},

How to check in jest that document.location.assign was called with specific url?

describe('sort', () => {
global.window = Object.create(window);
const url = "http://localhost:8080/uk/admin/students";
Object.defineProperty(window, 'location', {
    value: {
        href: url
    }
});
test('it calls assign with expected URL',async () => {
    window.location.assign = jest.fn();
    const wrapper = shallowMount(Students)
    await wrapper.find('.sort-by-id').trigger('click')
    await expect(window.location.assign).toHaveBeenCalledWith('/?&order=id-asc')
})

})

error in command line

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