@@ -74,7 +74,7 @@ Hopefully our `Model` class is self explanatory, but as an example,
7474here we construct a person object.
7575
7676``` javascript
77- var arthur = new Model (' person' );
77+ const arthur = new Model (' person' );
7878arthur .set (' name' , ' Arthur Dent' );
7979arthur .set (' occupation' , ' traveller' );
8080console .log (arthur .get (' name' )); // Arthur Dent
@@ -97,7 +97,7 @@ implementation throughout.
9797For this example, we want the following test case to pass:
9898
9999``` javascript
100- var arthur = new Model (' person' );
100+ const arthur = new Model (' person' );
101101expect (arthur).to .be .a .model ;
102102```
103103
@@ -141,7 +141,7 @@ expect(arthur).to.be.a.model('person');
141141
142142// language chain method
143143Assertion .addMethod (' model' , function (type ) {
144- var obj = this ._obj ;
144+ const obj = this ._obj ;
145145
146146 // first, our instanceof check, shortcut
147147 new Assertion (this ._obj ).to .be .instanceof (Model);
@@ -176,8 +176,8 @@ To understand when to best use chainable methods we will examine a chainable met
176176core.
177177
178178` ` ` javascript
179- var arr = [ 1 , 2 , 3 ]
180- , obj = { a: 1 , b: 2 };
179+ const arr = [ 1 , 2 , 3 ];
180+ const obj = { a: 1 , b: 2 };
181181
182182expect (arr).to .contain (2 );
183183expect (obj).to .contain .key (' a' );
@@ -241,7 +241,7 @@ function assertModelAge (n) {
241241 new Assertion (this ._obj ).to .be .instanceof (Model);
242242
243243 // make sure we have an age and its a number
244- var age = this ._obj .get (' age' );
244+ const age = this ._obj .get (' age' );
245245 new Assertion (age).to .be .a (' number' );
246246
247247 // do our comparison
@@ -301,7 +301,7 @@ Let's start out with the basic overwrite utility and a basic assertion.
301301` ` ` javascript
302302chai .overwriteProperty (' ok' , function (_super ) {
303303 return function checkModel () {
304- var obj = this ._obj ;
304+ const obj = this ._obj ;
305305 if (obj && obj instanceof Model) {
306306 new Assertion (obj).to .have .deep .property (' _attrs.id' ).a (' number' );
307307 } else {
@@ -324,7 +324,7 @@ will serve as the actual assertion.
324324With this in place, we can write positive assertions.
325325
326326` ` ` javascript
327- var arthur = new Model (' person' );
327+ const arthur = new Model (' person' );
328328arthur .set (' id' , 42 );
329329expect (arthur).to .be .ok ;
330330expect (true ).to .be .ok ;
@@ -336,7 +336,7 @@ revert to the original behavior. We will, however, run into a bit of
336336trouble if we try to negate an ` ok` assertion on a model.
337337
338338` ` ` javascript
339- var arthur = new Model (' person' );
339+ const arthur = new Model (' person' );
340340arthur .set (' id' , ' dont panic' );
341341expect (arthur).to .not .be .ok ;
342342` ` `
@@ -355,10 +355,10 @@ property overwrite would look like this.
355355` ` ` javascript
356356chai .overwriteProperty (' ok' , function (_super ) {
357357 return function checkModel () {
358- var obj = this ._obj ;
358+ const obj = this ._obj ;
359359 if (obj && obj instanceof Model) {
360360 new Assertion (obj).to .have .deep .property (' _attrs.id' ); // we always want this
361- var assertId = new Assertion (obj ._attrs .id );
361+ const assertId = new Assertion (obj ._attrs .id );
362362 utils .transferFlags (this , assertId, false ); // false means don't transfer `object` flag
363363 assertId .is .a (' number' );
364364 } else {
@@ -380,7 +380,7 @@ for the wrong type of id attribute, we would get an error message that states
380380test suite, so we will provide it with a bit more information.
381381
382382` ` ` javascript
383- var assertId = new Assertion (obj ._attrs .id , ' model assert ok id type' );
383+ const assertId = new Assertion (obj ._attrs .id , ' model assert ok id type' );
384384` ` `
385385
386386This will change our error message to be a more informative ` model assert ok id type:
@@ -393,7 +393,7 @@ For this example we will be returning to our example of asserting Arthur's
393393age to be above a minimum threshold.
394394
395395` ` ` javascript
396- var arthur = new Model (' person' );
396+ const arthur = new Model (' person' );
397397arthur .set (' age' , 27 );
398398expect (arthur).to .have .age .above (17 );
399399` ` `
@@ -405,7 +405,7 @@ so all we have to do is check if that exists.
405405Assertion .overwriteMethod (' above' , function (_super ) {
406406 return function assertAge (n ) {
407407 if (utils .flag (this , ' model.age' )) {
408- var obj = this ._obj ;
408+ const obj = this ._obj ;
409409
410410 // first we assert we are actually working with a model
411411 new Assertion (obj).instanceof (Model);
@@ -414,7 +414,7 @@ Assertion.overwriteMethod('above', function (_super) {
414414 new Assertion (obj).to .have .deep .property (' _attrs.age' ).a (' number' );
415415
416416 // now we compare
417- var age = obj .get (' age' );
417+ const age = obj .get (' age' );
418418 this .assert (
419419 age > n
420420 , " expected #{this} to have an age above #{exp} but got #{act}"
0 commit comments