|
2 | 2 | <html lang="en"> |
3 | 3 |
|
4 | 4 | <head> |
5 | | - <link rel="stylesheet" href="bower_components/mocha/mocha.css"> |
| 5 | + <meta charset="utf-8" /> |
| 6 | + <link rel="stylesheet" href="bower_components/mocha/mocha.css" /> |
6 | 7 | </head> |
7 | 8 |
|
8 | 9 | <body> |
|
11 | 12 | <script src="bower_components/mocha/mocha.js"></script> |
12 | 13 | <script src="bower_components/chai/chai.js"></script> |
13 | 14 |
|
14 | | - <script src="node_modules/sinon/pkg/sinon-1.16.1.js"></script> |
| 15 | + <script src="node_modules/sinon/pkg/sinon-1.17.6.js"></script> |
15 | 16 | <script src="bower_components/sinon-chai/lib/sinon-chai.js"></script> |
16 | | - <script type="text/javascript"> |
17 | | - mocha.setup('bdd'); |
18 | | - expect = chai.expect; |
19 | | - </script> |
20 | | - |
21 | | - <script> |
22 | | - function sum(numbers) { |
23 | | - if (!Array.isArray(numbers)) { |
24 | | - numbers = [].slice.call(arguments); |
25 | | - } |
26 | | - return numbers.reduce(function(s, number) { |
27 | | - return s + number; |
28 | | - }, 0); |
29 | | - } |
30 | | - |
31 | | - describe('#sum', function() { |
32 | | - it('expect sum(1,2,3) to equal 6', function() { |
33 | | - var actual = sum(1, 2, 3), |
34 | | - expected = 6; |
35 | | - expect(actual).to.equal(expected); |
36 | | - }) |
37 | | - it('expect sum([1,2,3]) to equal 6', function() { |
38 | | - var actual = sum([1, 2, 3]), |
39 | | - expected = 6; |
40 | | - expect(actual).to.equal(expected); |
41 | | - }) |
42 | | - it('expect sum() to equal 0', function() { |
43 | | - var actual = sum(), |
44 | | - expected = 0 ; |
45 | | - expect(actual).to.equal(expected); |
46 | | - }) |
47 | | - it('expect sum([]) to equal 0', function() { |
48 | | - var actual = sum([]), |
49 | | - expected = 0; |
50 | | - expect(actual).to.equal(expected); |
51 | | - }) |
52 | | - }); |
53 | | - |
54 | | - |
55 | | - describe('Sinon', function(){ |
56 | | - var messages; |
57 | | - beforeEach(function(){ |
58 | | - messages = []; |
59 | | - sinon.stub(console, 'log', function(msg){ |
60 | | - messages.push(msg); |
61 | | - }); |
62 | | - }); |
63 | | - |
64 | | - afterEach(function(){ |
65 | | - console.log.restore(); |
66 | | - }); |
67 | | - |
68 | | - it('Expect to capture the print to the console', function(){ |
69 | | - console.log('Hello!'); |
70 | | - |
71 | | - expect(console.log.called).to.be.true; |
72 | | - expect(console.log.calledWith('Hello!')).to.be.true; |
73 | | - expect(messages).to.eql(['Hello!']); |
74 | | - }); |
75 | | - }); |
76 | | - |
77 | | - </script> |
78 | | - <script type="text/javascript"> |
79 | | - mocha.run(); |
80 | | - </script> |
81 | 17 |
|
| 18 | + <script src="sum.js"></script> |
| 19 | + <script src="tests.js"></script> |
82 | 20 | </html> |
0 commit comments