mercredi 21 mars 2018

Unit test array contains object with property of itself

I have an array with 3 objects, each object should have a property of itself. I've already grouped the objects by a specific property, now I'd like to test that each object was successfully grouped.

I had something like

expect(array).to.include.something.that.includes({item: 'Car'});

before getting myself confused, have tried reading Chai/Jasmine docs

var A = [  { 
    Car:
       [ { color: 'Red', item: 'Car' },
         { color: 'Blue', item: 'Car' } ],

      Bike: [ { color: 'Blue', item: 'Bike' } ],

      Train: [ { color: 'Steel', item: 'Train' } ],
    } ];

Aucun commentaire:

Enregistrer un commentaire