Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

92
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda