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

126
Visualizações
Equality of ImageData objects with Jasmine

I want to test two ImageData objects for equality with Jasmine. The problem is, that the image dimensions are completely ignored in the comparison. What am I missing?

var img = new Uint8ClampedArray([138, 162, 148 255, 70, 29, 70, 20 0, 0, 0, 255, 255, 255, 255, 255, 46, 46, 46, 17, 139, 139, 139, 255]);
var imgA = new ImageData(img, 3, 2);
var imgB = new ImageData(img, 2, 3);

expect(imgA).toEqual(imgB);
done();

//SUCCESS

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Write a custom comparison so that it checks what you want it to check. In your case, you can use something like

  // comparator; note: untested code
  const imageEquality = (first, second) => {
    if (first.constructor == ImageData && second.constructor == ImageData) {
      return first.height == second.height
          && first.width == second.width
          && first.data.every((e,i) => e == second.data[i]));
    }
    return undefined; // we do not know how to compare that
  };

  // register to ensure that it is used in comparations
  beforeEach(function() {
    jasmine.addCustomEqualityTester(imageEquality);
  });
about 4 years ago · Juan Pablo Isaza Relatório
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