chaijs / chaijs.github.io

The chaijs.com website source code. Contributions welcome.
http://chaijs.github.io
49 stars 71 forks source link

Helper example won't run as is #193

Open jlaurens opened 3 years ago

jlaurens commented 3 years ago

The helpers page reads

Assertion.overwriteMethod('above', function (_super) {
  return function assertAge (n) {
    if (utils.flag(this, 'model.age')) {
       [...]

      // next, make sure we have an age
      new Assertion(obj).to.have.deep.property('_attrs.age').a('number'); //<<<< ERROR

      // now we compare
      [...]
  };
});

The assertion always fails because '_attrs.age' is not a valid property name.

If you do not want to remove it, simply replace it by

      new Assertion(obj._attrs).to.have.property('age').a('number');