mercredi 28 octobre 2015

Unit test compare value return from text() with toEqual()?

How to compare part of returns value from text() function which present in the unit test. For example I have angular application there is element . I want to test it thus that element is present and src attr has value "img.jpg".

Hope, I expressed my question correct.

Over there code:

Html markup:
     <img src="img.jpg"/>

Unit test:
it('must has image', function(){
var img = directiveElem.find('<img src="img.jpg">');
expect(img).toBeDefined();
expect(img.find('src="img.jpg"').text()).toEqual('img.jpg');

})

Aucun commentaire:

Enregistrer un commentaire