unit testing - Jasmine, test if Javascript Object Contains another Javascript Object -
i'm using jasmine , want test if object extending object.
actually want achieve sinon.calledwithmatch synchronous code.
jasmine's tomatch regex.
i'd able write like
it( 'contains' , function () { expect(objecta).to.contain(objectb); })
or
it( 'extends' , function () { expect(objecta).to.extend(objectb); })
thing feels obvious , i'd know if there proper way of achieving test i'm not aware of.
i'm answering own question explain have solution i'm looking 1 using actual framework, in case i'm missing
at moment i'm doing
var containsobject = function ( objecta , objectb) { var _match = true angular.foreach(objectb , function ( value, key ) { //any loop if (value !== objecta[key]) _match = false; }); return _match; }; expect( containsobject( newobjectwithmoregoodies, oldobject ).to.eql(true);
Comments
Post a Comment