Skip to content

Commit 0b2e359

Browse files
committed
test (examples): test examples and improve coverage in them
1 parent d6930df commit 0b2e359

File tree

4 files changed

+55
-49
lines changed

4 files changed

+55
-49
lines changed

__tests__/Contacts.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ describe('Contacts App', () => {
3131
expect(toJSON(app)).toMatchSnapshot('04. Add Test Contact')
3232

3333
nameField.simulate('change', {
34-
target: { name: 'name', value: 'Other Contact' }
34+
target: { name: 'name', value: '' }
3535
})
3636
emailField.simulate('change', {
37-
target: { name: 'email', value: 'other.contact@gmail.com' }
37+
target: { name: 'email', value: '' }
3838
})
3939
createButton.simulate('click')
4040
await Promise.resolve()
41-
expect(toJSON(app)).toMatchSnapshot('05. Add Other Contact')
41+
expect(toJSON(app)).toMatchSnapshot('05. Add Placeholder Contact')
4242
})
4343

4444
test('should edit contact', async () => {
@@ -92,7 +92,7 @@ describe('Contacts App', () => {
9292

9393
deleteButton.simulate('click')
9494
await Promise.resolve()
95-
expect(toJSON(app)).toMatchSnapshot('12. Delete Other Contact')
95+
expect(toJSON(app)).toMatchSnapshot('12. Delete Placeholder Contact')
9696

9797
deleteButton = app.find('.contact-display .zmdi-delete').at(0)
9898

__tests__/TodoMVC.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ describe('TodoMVC App', () => {
2525
await Promise.resolve()
2626
expect(toJSON(app)).toMatchSnapshot('03. Add Other Todo')
2727

28+
input.simulate('keyUp', {
29+
keyCode: 27,
30+
target: { value: 'Final Tod' }
31+
})
2832
input.simulate('keyUp', {
2933
keyCode: 13,
3034
target: { value: 'Final Todo' }

__tests__/__snapshots__/Contacts.test.js.snap

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ exports[`04. Add Test Contact 1`] = `
429429
</App>
430430
`;
431431
432-
exports[`05. Add Other Contact 1`] = `
432+
exports[`05. Add Placeholder Contact 1`] = `
433433
<App>
434434
<table>
435435
<thead>
@@ -484,19 +484,19 @@ exports[`05. Add Other Contact 1`] = `
484484
<EasyCompWrapper
485485
contact={
486486
Object {
487-
"email": "other.contact@gmail.com",
488-
"name": "Other Contact",
487+
"email": "Placeholder",
488+
"name": "Placeholder",
489489
}
490490
}
491491
>
492492
<tr
493493
className="contact-display"
494494
>
495495
<td>
496-
Other Contact
496+
Placeholder
497497
</td>
498498
<td>
499-
other.contact@gmail.com
499+
Placeholder
500500
</td>
501501
<td>
502502
<button
@@ -586,10 +586,10 @@ exports[`05. Add Other Contact 1`] = `
586586
<EasyCompWrapper>
587587
<tr class="contact-display">
588588
<td>
589-
Other Contact
589+
Placeholder
590590
</td>
591591
<td>
592-
other.contact@gmail.com
592+
Placeholder
593593
</td>
594594
<td>
595595
<button>
@@ -693,19 +693,19 @@ exports[`06. Switch Test Contact to Edit Mode 1`] = `
693693
<EasyCompWrapper
694694
contact={
695695
Object {
696-
"email": "other.contact@gmail.com",
697-
"name": "Other Contact",
696+
"email": "Placeholder",
697+
"name": "Placeholder",
698698
}
699699
}
700700
>
701701
<tr
702702
className="contact-display"
703703
>
704704
<td>
705-
Other Contact
705+
Placeholder
706706
</td>
707707
<td>
708-
other.contact@gmail.com
708+
Placeholder
709709
</td>
710710
<td>
711711
<button
@@ -802,10 +802,10 @@ exports[`06. Switch Test Contact to Edit Mode 1`] = `
802802
<EasyCompWrapper>
803803
<tr class="contact-display">
804804
<td>
805-
Other Contact
805+
Placeholder
806806
</td>
807807
<td>
808-
other.contact@gmail.com
808+
Placeholder
809809
</td>
810810
<td>
811811
<button>
@@ -909,19 +909,19 @@ exports[`07. Edit Test Contact name 1`] = `
909909
<EasyCompWrapper
910910
contact={
911911
Object {
912-
"email": "other.contact@gmail.com",
913-
"name": "Other Contact",
912+
"email": "Placeholder",
913+
"name": "Placeholder",
914914
}
915915
}
916916
>
917917
<tr
918918
className="contact-display"
919919
>
920920
<td>
921-
Other Contact
921+
Placeholder
922922
</td>
923923
<td>
924-
other.contact@gmail.com
924+
Placeholder
925925
</td>
926926
<td>
927927
<button
@@ -1018,10 +1018,10 @@ exports[`07. Edit Test Contact name 1`] = `
10181018
<EasyCompWrapper>
10191019
<tr class="contact-display">
10201020
<td>
1021-
Other Contact
1021+
Placeholder
10221022
</td>
10231023
<td>
1024-
other.contact@gmail.com
1024+
Placeholder
10251025
</td>
10261026
<td>
10271027
<button>
@@ -1116,19 +1116,19 @@ exports[`08. Cancel Test Contact edit 1`] = `
11161116
<EasyCompWrapper
11171117
contact={
11181118
Object {
1119-
"email": "other.contact@gmail.com",
1120-
"name": "Other Contact",
1119+
"email": "Placeholder",
1120+
"name": "Placeholder",
11211121
}
11221122
}
11231123
>
11241124
<tr
11251125
className="contact-display"
11261126
>
11271127
<td>
1128-
Other Contact
1128+
Placeholder
11291129
</td>
11301130
<td>
1131-
other.contact@gmail.com
1131+
Placeholder
11321132
</td>
11331133
<td>
11341134
<button
@@ -1218,10 +1218,10 @@ exports[`08. Cancel Test Contact edit 1`] = `
12181218
<EasyCompWrapper>
12191219
<tr class="contact-display">
12201220
<td>
1221-
Other Contact
1221+
Placeholder
12221222
</td>
12231223
<td>
1224-
other.contact@gmail.com
1224+
Placeholder
12251225
</td>
12261226
<td>
12271227
<button>
@@ -1325,19 +1325,19 @@ exports[`09. Switch Test Contact to edit Mode 1`] = `
13251325
<EasyCompWrapper
13261326
contact={
13271327
Object {
1328-
"email": "other.contact@gmail.com",
1329-
"name": "Other Contact",
1328+
"email": "Placeholder",
1329+
"name": "Placeholder",
13301330
}
13311331
}
13321332
>
13331333
<tr
13341334
className="contact-display"
13351335
>
13361336
<td>
1337-
Other Contact
1337+
Placeholder
13381338
</td>
13391339
<td>
1340-
other.contact@gmail.com
1340+
Placeholder
13411341
</td>
13421342
<td>
13431343
<button
@@ -1434,10 +1434,10 @@ exports[`09. Switch Test Contact to edit Mode 1`] = `
14341434
<EasyCompWrapper>
14351435
<tr class="contact-display">
14361436
<td>
1437-
Other Contact
1437+
Placeholder
14381438
</td>
14391439
<td>
1440-
other.contact@gmail.com
1440+
Placeholder
14411441
</td>
14421442
<td>
14431443
<button>
@@ -1541,19 +1541,19 @@ exports[`10. Edit Test Contact email 1`] = `
15411541
<EasyCompWrapper
15421542
contact={
15431543
Object {
1544-
"email": "other.contact@gmail.com",
1545-
"name": "Other Contact",
1544+
"email": "Placeholder",
1545+
"name": "Placeholder",
15461546
}
15471547
}
15481548
>
15491549
<tr
15501550
className="contact-display"
15511551
>
15521552
<td>
1553-
Other Contact
1553+
Placeholder
15541554
</td>
15551555
<td>
1556-
other.contact@gmail.com
1556+
Placeholder
15571557
</td>
15581558
<td>
15591559
<button
@@ -1650,10 +1650,10 @@ exports[`10. Edit Test Contact email 1`] = `
16501650
<EasyCompWrapper>
16511651
<tr class="contact-display">
16521652
<td>
1653-
Other Contact
1653+
Placeholder
16541654
</td>
16551655
<td>
1656-
other.contact@gmail.com
1656+
Placeholder
16571657
</td>
16581658
<td>
16591659
<button>
@@ -1748,19 +1748,19 @@ exports[`11. Save Test Contact edit 1`] = `
17481748
<EasyCompWrapper
17491749
contact={
17501750
Object {
1751-
"email": "other.contact@gmail.com",
1752-
"name": "Other Contact",
1751+
"email": "Placeholder",
1752+
"name": "Placeholder",
17531753
}
17541754
}
17551755
>
17561756
<tr
17571757
className="contact-display"
17581758
>
17591759
<td>
1760-
Other Contact
1760+
Placeholder
17611761
</td>
17621762
<td>
1763-
other.contact@gmail.com
1763+
Placeholder
17641764
</td>
17651765
<td>
17661766
<button
@@ -1850,10 +1850,10 @@ exports[`11. Save Test Contact edit 1`] = `
18501850
<EasyCompWrapper>
18511851
<tr class="contact-display">
18521852
<td>
1853-
Other Contact
1853+
Placeholder
18541854
</td>
18551855
<td>
1856-
other.contact@gmail.com
1856+
Placeholder
18571857
</td>
18581858
<td>
18591859
<button>
@@ -1893,7 +1893,7 @@ exports[`11. Save Test Contact edit 1`] = `
18931893
</App>
18941894
`;
18951895
1896-
exports[`12. Delete Other Contact 1`] = `
1896+
exports[`12. Delete Placeholder Contact 1`] = `
18971897
<App>
18981898
<table>
18991899
<thead>

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
"./node_modules/jest-html"
2323
],
2424
"collectCoverageFrom": [
25-
"**/src/**"
25+
"**/src/**",
26+
"**/examples/**",
27+
"!**/examples/**/index.jsx"
2628
]
2729
},
2830
"author": {

0 commit comments

Comments
 (0)