Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 44adbe7

Browse files
committedApr 19, 2016
Fix broken tests
1 parent d7abfb5 commit 44adbe7

File tree

7 files changed

+77
-38
lines changed

7 files changed

+77
-38
lines changed
 

‎step-5-done/tests/components/wine-app.spec.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ import { createMemoryHistory } from 'react-router';
77

88
import { App } from '../../src/app';
99

10+
String.prototype.contains = function(what) {
11+
return this.indexOf(what) > -1;
12+
};
13+
1014
const regions = ['Bordeaux', 'Bourgogne'];
1115

1216
const wines1 = [
@@ -282,20 +286,20 @@ describe('<App />', () => {
282286
const like = wrapper.find('Wine').find('span').filterWhere(n => n.get(0).innerHTML === 'like');
283287
expect(like.length).to.equal(1);
284288

285-
expect(wrapper.find('Stats').contains(<div><span>likes : </span><span>0</span></div>));
289+
expect(wrapper.find('Stats').html().contains('<div><span>likes : </span><span>0</span></div>')).to.equals(true);
286290

287291
like.simulate('click');
288292

289293
const like2 = wrapper.find('Wine').find('span').filterWhere(n => n.get(0).innerHTML === 'unlike');
290294
expect(like2.length).to.equal(1);
291295

292-
expect(wrapper.find('Stats').contains(<div><span>likes : </span><span>1</span></div>));
296+
expect(wrapper.find('Stats').html().contains('<div><span>likes : </span><span>1</span></div>')).to.equals(true);
293297

294298
like2.simulate('click');
295299

296300
const like3 = wrapper.find('Wine').find('span').filterWhere(n => n.get(0).innerHTML === 'like');
297301
expect(like3.length).to.equal(1);
298-
expect(wrapper.find('Stats').contains(<div><span>likes : </span><span>0</span></div>));
302+
expect(wrapper.find('Stats').html().contains('<div><span>likes : </span><span>0</span></div>')).to.equals(true);
299303
});
300304

301305
it('doit afficher un vin et poster un commentaire tout en incrémentant les stats globales', () => {
@@ -315,7 +319,7 @@ describe('<App />', () => {
315319
let paragraphs = wrapper.find('Comments').find('p');
316320
expect(paragraphs.length).to.equals(0);
317321

318-
expect(wrapper.find('Stats').contains(<div><span>comments : </span><span>0</span></div>));
322+
expect(wrapper.find('Stats').html().contains('<div><span>comments : </span><span>0</span></div>')).to.equals(true);
319323

320324
wrapper.find('Comments').find('input').simulate('change', { target: { value: 'Comment 1' } });
321325
wrapper.find('Comments').find('textarea').simulate('change', { target: { value: 'Comment 1 body' } });
@@ -324,6 +328,6 @@ describe('<App />', () => {
324328
paragraphs = wrapper.find('Comments').find('p');
325329
expect(paragraphs.length).to.equals(1);
326330
expect(paragraphs.at(0).html()).to.equals('<p>Comment 1 body</p>');
327-
expect(wrapper.find('Stats').contains(<div><span>comments : </span><span>1</span></div>));
331+
expect(wrapper.find('Stats').html().contains('<div><span>comments : </span><span>1</span></div>')).to.equals(true);
328332
});
329333
});

‎step-5/tests/components/wine-app.spec.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ import { createMemoryHistory } from 'react-router';
77

88
import { App } from '../../src/app';
99

10+
String.prototype.contains = function(what) {
11+
return this.indexOf(what) > -1;
12+
};
13+
1014
const regions = ['Bordeaux', 'Bourgogne'];
1115

1216
const wines1 = [
@@ -282,20 +286,20 @@ describe('<App />', () => {
282286
const like = wrapper.find('Wine').find('span').filterWhere(n => n.get(0).innerHTML === 'like');
283287
expect(like.length).to.equal(1);
284288

285-
expect(wrapper.find('Stats').contains(<div><span>likes : </span><span>0</span></div>));
289+
expect(wrapper.find('Stats').html().contains('<div><span>likes : </span><span>0</span></div>')).to.equals(true);
286290

287291
like.simulate('click');
288292

289293
const like2 = wrapper.find('Wine').find('span').filterWhere(n => n.get(0).innerHTML === 'unlike');
290294
expect(like2.length).to.equal(1);
291295

292-
expect(wrapper.find('Stats').contains(<div><span>likes : </span><span>1</span></div>));
296+
expect(wrapper.find('Stats').html().contains('<div><span>likes : </span><span>1</span></div>')).to.equals(true);
293297

294298
like2.simulate('click');
295299

296300
const like3 = wrapper.find('Wine').find('span').filterWhere(n => n.get(0).innerHTML === 'like');
297301
expect(like3.length).to.equal(1);
298-
expect(wrapper.find('Stats').contains(<div><span>likes : </span><span>0</span></div>));
302+
expect(wrapper.find('Stats').html().contains('<div><span>likes : </span><span>0</span></div>')).to.equals(true);
299303
});
300304

301305
it('doit afficher un vin et poster un commentaire tout en incrémentant les stats globales', () => {
@@ -315,7 +319,7 @@ describe('<App />', () => {
315319
let paragraphs = wrapper.find('Comments').find('p');
316320
expect(paragraphs.length).to.equals(0);
317321

318-
expect(wrapper.find('Stats').contains(<div><span>comments : </span><span>0</span></div>));
322+
expect(wrapper.find('Stats').html().contains('<div><span>comments : </span><span>0</span></div>')).to.equals(true);
319323

320324
wrapper.find('Comments').find('input').simulate('change', { target: { value: 'Comment 1' } });
321325
wrapper.find('Comments').find('textarea').simulate('change', { target: { value: 'Comment 1 body' } });
@@ -324,6 +328,6 @@ describe('<App />', () => {
324328
paragraphs = wrapper.find('Comments').find('p');
325329
expect(paragraphs.length).to.equals(1);
326330
expect(paragraphs.at(0).html()).to.equals('<p>Comment 1 body</p>');
327-
expect(wrapper.find('Stats').contains(<div><span>comments : </span><span>1</span></div>));
331+
expect(wrapper.find('Stats').html().contains('<div><span>comments : </span><span>1</span></div>')).to.equals(true);
328332
});
329333
});

‎step-6-done/tests/components/wine-app.spec.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ import { createMemoryHistory } from 'react-router';
77

88
import { App } from '../../src/app';
99

10+
String.prototype.contains = function(what) {
11+
return this.indexOf(what) > -1;
12+
};
13+
1014
const regions = ['Bordeaux', 'Bourgogne'];
1115

1216
const wines1 = [
@@ -298,19 +302,19 @@ describe('<App />', () => {
298302

299303
const like = wrapper.find('Wine').find('span').filterWhere(n => n.get(0).innerHTML === 'like');
300304
expect(like.length).to.equal(1);
301-
expect(wrapper.find('Stats').contains(<div><span>likes : </span><span>0</span></div>));
305+
expect(wrapper.find('GlobalStats').html().contains('<div><span>likes : </span><span>0</span></div>')).to.equals(true);
302306

303307
like.simulate('click');
304308

305309
const like2 = wrapper.find('Wine').find('span').filterWhere(n => n.get(0).innerHTML === 'unlike');
306310
expect(like2.length).to.equal(1);
307-
expect(wrapper.find('Stats').contains(<div><span>likes : </span><span>1</span></div>));
311+
expect(wrapper.find('GlobalStats').html().contains('<div><span>likes : </span><span>1</span></div>')).to.equals(true);
308312

309313
like2.simulate('click');
310314

311315
const like3 = wrapper.find('Wine').find('span').filterWhere(n => n.get(0).innerHTML === 'like');
312316
expect(like3.length).to.equal(1);
313-
expect(wrapper.find('Stats').contains(<div><span>likes : </span><span>0</span></div>));
317+
expect(wrapper.find('GlobalStats').html().contains('<div><span>likes : </span><span>0</span></div>')).to.equals(true);
314318

315319
history.goBack();
316320
history.goBack();
@@ -332,7 +336,7 @@ describe('<App />', () => {
332336

333337
let paragraphs = wrapper.find('Comments').find('p');
334338
expect(paragraphs.length).to.equals(0);
335-
expect(wrapper.find('Stats').contains(<div><span>comments : </span><span>0</span></div>));
339+
expect(wrapper.find('GlobalStats').html().contains('<div><span>comments : </span><span>0</span></div>')).to.equals(true);
336340

337341
wrapper.find('Comments').find('input').simulate('change', { target: { value: 'Comment 1' } });
338342
wrapper.find('Comments').find('textarea').simulate('change', { target: { value: 'Comment 1 body' } });
@@ -341,7 +345,7 @@ describe('<App />', () => {
341345
paragraphs = wrapper.find('Comments').find('p');
342346
expect(paragraphs.length).to.equals(1);
343347
expect(paragraphs.at(0).html()).to.equals('<p>Comment 1 body</p>');
344-
expect(wrapper.find('Stats').contains(<div><span>comments : </span><span>1</span></div>));
348+
expect(wrapper.find('GlobalStats').html().contains('<div><span>comments : </span><span>1</span></div>')).to.equals(true);
345349

346350
history.goBack();
347351
history.goBack();

‎step-6/tests/components/wine-app.spec.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ import { createMemoryHistory } from 'react-router';
77

88
import { App } from '../../src/app';
99

10+
String.prototype.contains = function(what) {
11+
return this.indexOf(what) > -1;
12+
};
13+
1014
const regions = ['Bordeaux', 'Bourgogne'];
1115

1216
const wines1 = [
@@ -294,20 +298,20 @@ describe('<App />', () => {
294298
const like = wrapper.find('Wine').find('span').filterWhere(n => n.get(0).innerHTML === 'like');
295299
expect(like.length).to.equal(1);
296300

297-
expect(wrapper.find('Stats').contains(<div><span>likes : </span><span>0</span></div>));
301+
expect(wrapper.find('GlobalStats').html().contains('<div><span>likes : </span><span>0</span></div>')).to.equals(true);
298302

299303
like.simulate('click');
300304

301305
const like2 = wrapper.find('Wine').find('span').filterWhere(n => n.get(0).innerHTML === 'unlike');
302306
expect(like2.length).to.equal(1);
303307

304-
expect(wrapper.find('Stats').contains(<div><span>likes : </span><span>1</span></div>));
308+
expect(wrapper.find('GlobalStats').html().contains('<div><span>likes : </span><span>1</span></div>')).to.equals(true);
305309

306310
like2.simulate('click');
307311

308312
const like3 = wrapper.find('Wine').find('span').filterWhere(n => n.get(0).innerHTML === 'like');
309313
expect(like3.length).to.equal(1);
310-
expect(wrapper.find('Stats').contains(<div><span>likes : </span><span>0</span></div>));
314+
expect(wrapper.find('GlobalStats').html().contains('<div><span>likes : </span><span>0</span></div>')).to.equals(true);
311315
});
312316

313317
it('doit afficher un vin et poster un commentaire tout en incrémentant les stats globales', () => {
@@ -327,7 +331,7 @@ describe('<App />', () => {
327331
let paragraphs = wrapper.find('Comments').find('p');
328332
expect(paragraphs.length).to.equals(0);
329333

330-
expect(wrapper.find('Stats').contains(<div><span>comments : </span><span>0</span></div>));
334+
expect(wrapper.find('GlobalStats').html().contains('<div><span>comments : </span><span>0</span></div>')).to.equals(true);
331335

332336
wrapper.find('Comments').find('input').simulate('change', { target: { value: 'Comment 1' } });
333337
wrapper.find('Comments').find('textarea').simulate('change', { target: { value: 'Comment 1 body' } });
@@ -336,6 +340,6 @@ describe('<App />', () => {
336340
paragraphs = wrapper.find('Comments').find('p');
337341
expect(paragraphs.length).to.equals(1);
338342
expect(paragraphs.at(0).html()).to.equals('<p>Comment 1 body</p>');
339-
expect(wrapper.find('Stats').contains(<div><span>comments : </span><span>1</span></div>));
343+
expect(wrapper.find('GlobalStats').html().contains('<div><span>comments : </span><span>1</span></div>')).to.equals(true);
340344
});
341345
});

‎step-7/tests/components/wine-app.spec.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ import { createMemoryHistory } from 'react-router';
77

88
import { App } from '../../src/app';
99

10+
String.prototype.contains = function(what) {
11+
return this.indexOf(what) > -1;
12+
};
13+
1014
const regions = ['Bordeaux', 'Bourgogne'];
1115

1216
const wines1 = [
@@ -298,19 +302,19 @@ describe('<App />', () => {
298302

299303
const like = wrapper.find('Wine').find('span').filterWhere(n => n.get(0).innerHTML === 'like');
300304
expect(like.length).to.equal(1);
301-
expect(wrapper.find('Stats').contains(<div><span>likes : </span><span>0</span></div>));
305+
expect(wrapper.find('GlobalStats').html().contains('<div><span>likes : </span><span>0</span></div>')).to.equals(true);
302306

303307
like.simulate('click');
304308

305309
const like2 = wrapper.find('Wine').find('span').filterWhere(n => n.get(0).innerHTML === 'unlike');
306310
expect(like2.length).to.equal(1);
307-
expect(wrapper.find('Stats').contains(<div><span>likes : </span><span>1</span></div>));
311+
expect(wrapper.find('GlobalStats').html().contains('<div><span>likes : </span><span>1</span></div>')).to.equals(true);
308312

309313
like2.simulate('click');
310314

311315
const like3 = wrapper.find('Wine').find('span').filterWhere(n => n.get(0).innerHTML === 'like');
312316
expect(like3.length).to.equal(1);
313-
expect(wrapper.find('Stats').contains(<div><span>likes : </span><span>0</span></div>));
317+
expect(wrapper.find('GlobalStats').html().contains('<div><span>likes : </span><span>0</span></div>')).to.equals(true);
314318

315319
history.goBack();
316320
history.goBack();
@@ -332,7 +336,7 @@ describe('<App />', () => {
332336

333337
let paragraphs = wrapper.find('Comments').find('p');
334338
expect(paragraphs.length).to.equals(0);
335-
expect(wrapper.find('Stats').contains(<div><span>comments : </span><span>0</span></div>));
339+
expect(wrapper.find('GlobalStats').html().contains('<div><span>comments : </span><span>0</span></div>')).to.equals(true);
336340

337341
wrapper.find('Comments').find('input').simulate('change', { target: { value: 'Comment 1' } });
338342
wrapper.find('Comments').find('textarea').simulate('change', { target: { value: 'Comment 1 body' } });
@@ -341,7 +345,7 @@ describe('<App />', () => {
341345
paragraphs = wrapper.find('Comments').find('p');
342346
expect(paragraphs.length).to.equals(1);
343347
expect(paragraphs.at(0).html()).to.equals('<p>Comment 1 body</p>');
344-
expect(wrapper.find('Stats').contains(<div><span>comments : </span><span>1</span></div>));
348+
expect(wrapper.find('GlobalStats').html().contains('<div><span>comments : </span><span>1</span></div>')).to.equals(true);
345349

346350
history.goBack();
347351
history.goBack();

‎test-all-done.sh

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@
22

33
APP_PATH=`pwd`
44

5-
STEPS=`find $APP_PATH -type d -name "step-*-done"`
6-
7-
for item in ${STEPS}
8-
do
9-
if [ -f "$item/package.json" ];
10-
then
11-
cd "$item"
12-
npm test
13-
else
14-
echo "nothing to do for $item"
15-
fi
16-
done
17-
5+
cd "$APP_PATH/step-1-done"
6+
npm test
7+
cd "$APP_PATH/step-2-done"
8+
npm test
9+
cd "$APP_PATH/step-3-done"
10+
npm test
11+
cd "$APP_PATH/step-4-done"
12+
npm test
13+
cd "$APP_PATH/step-5-done"
14+
npm test
15+
cd "$APP_PATH/step-6-done"
16+
npm test
1817
cd "$APP_PATH/step-7"
1918
npm test
19+
20+
cd "$APP_PATH"

‎test-all-undone.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
APP_PATH=`pwd`
4+
5+
cd "$APP_PATH/step-2"
6+
npm test
7+
cd "$APP_PATH/step-3"
8+
npm test
9+
cd "$APP_PATH/step-4"
10+
npm test
11+
cd "$APP_PATH/step-5"
12+
npm test
13+
cd "$APP_PATH/step-6"
14+
npm test
15+
cd "$APP_PATH/step-7"
16+
npm test
17+
18+
cd "$APP_PATH"

0 commit comments

Comments
 (0)
Please sign in to comment.