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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -