From 7059b9f59f16aed46df97fb75fc7acc39b2e42d4 Mon Sep 17 00:00:00 2001 From: Moti Shani Date: Wed, 22 Nov 2017 15:49:31 +0200 Subject: [PATCH 1/2] article1.md - fix mocha args so tests will not hang --- article1.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/article1.md b/article1.md index 1583f97..121a736 100644 --- a/article1.md +++ b/article1.md @@ -51,7 +51,7 @@ describe('CartSummary', function() { The `describe` function is used to set up a group of tests with a name. I tend to put the module under test as the name, in this case `CartSummary`. A test is written using the `it` function. The `it` function is given a description as the first argument of what the module under test should do. The second argument of the `it` function is a function that will contain one or more assertions (also called expectations) using Chai in this example. Our first test simply verifies that the subtotal is 0 if the cart has no items. -To run this test, run `mocha tests --recursive --watch` from the root of the project. The recursive flag will find all files in subdirectories, and the watch flag will watch all your source and test files and rerun the tests when they change. You should see something like this: +To run this test, run `mocha tests --recursive --expose-internals` from the root of the project. The recursive flag will find all files in subdirectories, and the watch flag will watch all your source and test files and rerun the tests when they change. You should see something like this: ![failing-test-1.png](failing-test-1.png) From 81b1a9ee8cffcbc13cb0dfe98fe12887fa2169e1 Mon Sep 17 00:00:00 2001 From: Moti Shani Date: Thu, 23 Nov 2017 10:25:37 +0200 Subject: [PATCH 2/2] use stub.(obj,meth).callsFake(fn) as stub(obj, 'meth', fn) has been removed --- article1.md | 3 ++- tests/part1/cart-summary-test.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/article1.md b/article1.md index 121a736..7dd436b 100644 --- a/article1.md +++ b/article1.md @@ -156,9 +156,10 @@ Now that `tax.calculate` has been created, we can stub it out with our pre-progr var sinon = require('sinon'); var tax = require('./../../src/part1/tax'); + describe('getTax()', function() { beforeEach(function() { - sinon.stub(tax, 'calculate', function(subtotal, state, done) { + sinon.stub(tax, 'calculate').callsFake(function(subtotal, state, done) { setTimeout(function() { done({ amount: 30 diff --git a/tests/part1/cart-summary-test.js b/tests/part1/cart-summary-test.js index 330d069..f84368a 100644 --- a/tests/part1/cart-summary-test.js +++ b/tests/part1/cart-summary-test.js @@ -6,7 +6,7 @@ var tax = require('./../../src/part1/tax'); describe('CartSummary', function() { beforeEach(function() { - sinon.stub(tax, 'calculate', function(subtotal, state, done) { + sinon.stub(tax, 'calculate').callsFake(function(subtotal, state, done) { setTimeout(function() { done({ amount: 30