I'm unit testing methods that are applied on an array and change its items states. Those items have different properties. For example, my array is the following :
var array = [{state: false}, {status: true}, {health: true}];
After the method is applied (items order is relevant), I'm checking that the values have changed and are the ones I expect (I'm using mocha, chai) :
expect(array[0]).to.have.property('state', true);
expect(array[1]).to.have.property('status', false);
expect(array[2]).to.have.property('health', false);
Now, say that I want to add new energy items to my array :
var array = [{state: false}, **{energy: true}**, {status: true}, **{energy: true}**, {health: true}];
I would have to changes my 0, 1, 2 indexes of my test to 0, 2, 4, and also add new tests for my new items.
What would be a good way of using (or not using) indexes so that each time I add new items types, I don't have to change all indexes ?
Aucun commentaire:
Enregistrer un commentaire