jeudi 2 juin 2016

Cannot compare HTML string in karma/jasmine/PhantomJS test because of icon

I have test which should check if element html rendered by my factory is correct, however this element contains material icon and it seems to be impossible to compare it in this test.

Simplified test case:

describe( 'Compile: ', function () {
  it( 'show that those two html strings are the equal', function () {
    var mockEl = $( '<i class="material-icons">&#xE24B;</i>' )
      ;
    expect( mockEl.html() ).toBe(
      '<i class="material-icons">&#xE24B;</i>'
    );    
  } );
} );

In result I test throws error: Expected '' to be '<i class="material-icons">&#xE24B;</i>'.

EDIT: Have the same error when use innerHTML instead jQuery (just in case)

Aucun commentaire:

Enregistrer un commentaire