|
| 1 | +'use strict'; |
| 2 | +var chai = require('chai'); |
| 3 | +var spies = require('chai-spies'); |
| 4 | +var expect = chai.expect; |
| 5 | +chai.use(spies); |
| 6 | +var spy = chai.spy.on(console, 'log'); |
| 7 | + |
| 8 | +// use => |
| 9 | +const greet = function (name) { |
| 10 | + return 'hello ' + name; |
| 11 | +} |
| 12 | + |
| 13 | + |
| 14 | +describe('01 greet', () => { |
| 15 | + |
| 16 | + it('doesn\'t exist', () => { |
| 17 | + expect(greet).to.be.defined; |
| 18 | + }); |
| 19 | + |
| 20 | + it('doesn\'t use an arrow function', () => { |
| 21 | + expect(greet.toString()).to.match(/=>/g); |
| 22 | + }); |
| 23 | + |
| 24 | + it('doesn\'t return "hello " + name', () => { |
| 25 | + expect(greet('there')).to.equal('hello there'); |
| 26 | + }); |
| 27 | + |
| 28 | +}); |
| 29 | + |
| 30 | +describe('02 getName', () => { |
| 31 | + |
| 32 | + it('doesn\'t exist', () => { |
| 33 | + expect(getName).to.be.defined; |
| 34 | + }); |
| 35 | + |
| 36 | + it('doesn\'t use an arrow function', () => { |
| 37 | + expect(getName.toString()).to.match(/=>/g); |
| 38 | + }); |
| 39 | + |
| 40 | + it('should not use the `return` keyword', () => { |
| 41 | + expect(getName.toString()).not.to.match(/return/g); |
| 42 | + }); |
| 43 | + |
| 44 | + it('doesn\'t return the name "Joe"', () => { |
| 45 | + expect(getName()).to.equal('Joe'); |
| 46 | + }); |
| 47 | + |
| 48 | +}); |
| 49 | + |
| 50 | +describe('03 clock', () => { |
| 51 | + |
| 52 | + it('try the example on CodePen', () => { |
| 53 | + expect(true).to.equal(true); |
| 54 | + }); |
| 55 | + |
| 56 | +}); |
| 57 | + |
0 commit comments