@@ -723,7 +723,7 @@ Now let's try re-introducing the code we hacked together in our spike,
723
723
into _lists.js_:
724
724
725
725
726
- [role="sourcecode dofirst-ch16l013 "]
726
+ [role="sourcecode"]
727
727
.src/lists/static/lists.js (ch16l014)
728
728
====
729
729
[source,html]
@@ -744,7 +744,8 @@ That doesn't work! We get an _unexpected error_:
744
744
[subs="specialcharacters,quotes"]
745
745
----
746
746
2 specs, 2 failures, randomized with seed 12345 finished in 0.005s
747
- Error during loading: TypeError: textInput is null in file:///...goat-book/src/lists/static/lists.js line 2
747
+ Error during loading: TypeError: textInput is null in
748
+ file:///...goat-book/src/lists/static/lists.js line 2
748
749
Spec List | Failures
749
750
750
751
Superlists tests > error message should be hidden on input
@@ -767,7 +768,7 @@ Expected true to be false.
767
768
((("HTML fixtures")))
768
769
One of the difficulties with JavaScript in general, and testing in particular,
769
770
is in understanding the order of execution of our code (i.e., what happens when).
770
- When does our code in 'list.js' run, and when does each of our tests run? And
771
+ When does our code in _lists.js_ run, and when does each of our tests run? And
771
772
how does that interact with global state, that is, the DOM of our web page,
772
773
and the fixtures that we've already seen are supposed to be cleaned up after each test?
773
774
@@ -809,7 +810,7 @@ And the same in our actual JS code:
809
810
810
811
811
812
[role="sourcecode"]
812
- .src/lists/static/list .js (ch16l016)
813
+ .src/lists/static/lists .js (ch16l016)
813
814
====
814
815
[source,javascript]
815
816
----
@@ -818,7 +819,7 @@ const textInput = document.querySelector("#id_text");
818
819
textInput.oninput = () => {
819
820
const errorMsg = document.querySelector(".invalid-feedback");
820
821
errorMsg.style.display = "none";
821
- }
822
+ };
822
823
----
823
824
====
824
825
@@ -832,7 +833,7 @@ image::images/jasmine-console-logs.png["Jasmine tests with console.log debug out
832
833
833
834
What do we see?
834
835
835
- * 'list.js' loads first
836
+ * _lists.js_ loads first
836
837
* then we see the error saying `textInput is null`
837
838
* then we see our tests loading in Spec.js
838
839
* then we see a `beforeEach`, which is when our test fixture actually gets added to the DOM
@@ -873,7 +874,7 @@ And in our tests file, we call `initialize()` in our key test:
873
874
874
875
875
876
[role="sourcecode"]
876
- .src/lists/static/tests/tests.html (ch16l018)
877
+ .src/lists/static/tests/Spec.js (ch16l018)
877
878
====
878
879
[source,javascript]
879
880
----
@@ -916,6 +917,7 @@ Superlists tests
916
917
917
918
And now the `console.log` outputs should make more sense:
918
919
920
+ [role="skipme"]
919
921
----
920
922
lists.js loading lists.js:1:9
921
923
Spec.js loading Spec.js:1:9
@@ -955,7 +957,7 @@ Oh dear, sure enough the tests just pass:
955
957
[role="jasmine-output"]
956
958
[subs="specialcharacters,quotes"]
957
959
----
958
- 2 specs, 0 failures, randomized with seed 12345 finished in 0.005s
960
+ 2 specs, 0 failures, randomized with seed 12345 finished in 0.005s
959
961
960
962
961
963
Superlists tests
@@ -995,7 +997,7 @@ That gives us our expected failure:
995
997
[role="jasmine-output"]
996
998
[subs="specialcharacters,quotes"]
997
999
----
998
- 3 specs, 1 failure, randomized with seed 12345 finished in 0.005s
1000
+ 3 specs, 1 failure, randomized with seed 12345 finished in 0.005s
999
1001
1000
1002
Spec List | Failures
1001
1003
@@ -1129,7 +1131,7 @@ We've only refactored the tests so far, let's check they still pass:
1129
1131
[role="jasmine-output"]
1130
1132
[subs="specialcharacters,quotes"]
1131
1133
----
1132
- 3 specs, 0 failures, randomized with seed 12345 finished in 0.005s
1134
+ 3 specs, 0 failures, randomized with seed 12345 finished in 0.005s
1133
1135
1134
1136
1135
1137
Superlists tests
@@ -1175,7 +1177,7 @@ Now we look at the tests:
1175
1177
[role="jasmine-output"]
1176
1178
[subs="specialcharacters,quotes"]
1177
1179
----
1178
- 3 specs, 0 failures, randomized with seed 12345 finished in 0.005s
1180
+ 3 specs, 0 failures, randomized with seed 12345 finished in 0.005s
1179
1181
1180
1182
1181
1183
Superlists tests
@@ -1217,7 +1219,7 @@ And the tests still pass:
1217
1219
[role="jasmine-output"]
1218
1220
[subs="specialcharacters,quotes"]
1219
1221
----
1220
- 3 specs, 0 failures, randomized with seed 12345 finished in 0.005s
1222
+ 3 specs, 0 failures, randomized with seed 12345 finished in 0.005s
1221
1223
----
1222
1224
1223
1225
@@ -1239,7 +1241,7 @@ Phew, that gives us a failure:
1239
1241
[role="jasmine-output"]
1240
1242
[subs="specialcharacters,quotes"]
1241
1243
----
1242
- 3 specs, 1 failure, randomized with seed 12345 finished in 0.005s
1244
+ 3 specs, 1 failure, randomized with seed 12345 finished in 0.005s
1243
1245
1244
1246
Spec List | Failures
1245
1247
@@ -1253,7 +1255,7 @@ Expected true to be false.
1253
1255
Ok, back to the right way around:
1254
1256
1255
1257
[role="sourcecode"]
1256
- .src/lists/static/lists.js (ch16l026 )
1258
+ .src/lists/static/lists.js (ch16l027 )
1257
1259
====
1258
1260
[source,javascript]
1259
1261
----
@@ -1281,7 +1283,7 @@ with the right selectors:
1281
1283
1282
1284
<script src="/static/lists.js"></script>
1283
1285
<script>
1284
- initialize("input #id_text", "div .invalid-feedback");
1286
+ initialize("#id_text", ".invalid-feedback");
1285
1287
</script>
1286
1288
1287
1289
</body>
@@ -1356,7 +1358,7 @@ Oh dear, it seems like that doesn't quite work:
1356
1358
[role="jasmine-output"]
1357
1359
[subs="specialcharacters,quotes"]
1358
1360
----
1359
- 3 specs, 1 failure, randomized with seed 12345 finished in 0.005s
1361
+ 3 specs, 1 failure, randomized with seed 12345 finished in 0.005s
1360
1362
1361
1363
Spec List | Failures
1362
1364
@@ -1398,7 +1400,7 @@ That gets us back to passing tests:
1398
1400
[role="jasmine-output"]
1399
1401
[subs="specialcharacters,quotes"]
1400
1402
----
1401
- 3 specs, 0 failures, randomized with seed 12345 finished in 0.005s
1403
+ 3 specs, 0 failures, randomized with seed 12345 finished in 0.005s
1402
1404
1403
1405
1404
1406
Superlists tests
0 commit comments