mardi 10 novembre 2015

Expect all subobjects to contain property

I want to assert that all subobjects in this object contain a open property that is true:

var groups = {
    'Group1': {
        open: true,
        entries: [...]
    },
    'Group2': {
        open: true,
        entries: [...]
    },
    'Group3': {
        open: true,
        entries: [...]
    }
}

for now I'm doing:

angular.forEach(groups, function(group) {
    expect(group.open).to.be.true;
})

is there any chai matcher that could simplify this. e.g.

expect(groups).to.all.have.property('open', true)

Aucun commentaire:

Enregistrer un commentaire