mercredi 29 juin 2016

Expect deep property to have any of multiple values

In Chai assertion library, we can assert a deep property to exist and have a value:

expect(obj).to.have.deep.property("field1.field2", 1);

But, what if we need to assert this property to have one of multiple values? In this case, the test should pass if obj has a field1.field2 property that has 0 or 1 or 2 value.


FYI, I need this to check that a ESLint plugin ships with a recommended rules configuration that has a "warning level" configured for every rule. Warning level can be of 0, 1 or 2 values.

Aucun commentaire:

Enregistrer un commentaire