Skip to content

Commit 1739f64

Browse files
committed
more tweaks in 16
1 parent bc288d0 commit 1739f64

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

chapter_16_javascript.asciidoc

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ Now let's try re-introducing the code we hacked together in our spike,
723723
into _lists.js_:
724724

725725

726-
[role="sourcecode dofirst-ch16l013"]
726+
[role="sourcecode"]
727727
.src/lists/static/lists.js (ch16l014)
728728
====
729729
[source,html]
@@ -744,7 +744,8 @@ That doesn't work! We get an _unexpected error_:
744744
[subs="specialcharacters,quotes"]
745745
----
746746
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
748749
Spec List | Failures
749750
750751
Superlists tests > error message should be hidden on input
@@ -767,7 +768,7 @@ Expected true to be false.
767768
((("HTML fixtures")))
768769
One of the difficulties with JavaScript in general, and testing in particular,
769770
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
771772
how does that interact with global state, that is, the DOM of our web page,
772773
and the fixtures that we've already seen are supposed to be cleaned up after each test?
773774

@@ -809,7 +810,7 @@ And the same in our actual JS code:
809810

810811

811812
[role="sourcecode"]
812-
.src/lists/static/list.js (ch16l016)
813+
.src/lists/static/lists.js (ch16l016)
813814
====
814815
[source,javascript]
815816
----
@@ -818,7 +819,7 @@ const textInput = document.querySelector("#id_text");
818819
textInput.oninput = () => {
819820
const errorMsg = document.querySelector(".invalid-feedback");
820821
errorMsg.style.display = "none";
821-
}
822+
};
822823
----
823824
====
824825

@@ -832,7 +833,7 @@ image::images/jasmine-console-logs.png["Jasmine tests with console.log debug out
832833

833834
What do we see?
834835

835-
* 'list.js' loads first
836+
* _lists.js_ loads first
836837
* then we see the error saying `textInput is null`
837838
* then we see our tests loading in Spec.js
838839
* 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:
873874

874875

875876
[role="sourcecode"]
876-
.src/lists/static/tests/tests.html (ch16l018)
877+
.src/lists/static/tests/Spec.js (ch16l018)
877878
====
878879
[source,javascript]
879880
----
@@ -916,6 +917,7 @@ Superlists tests
916917

917918
And now the `console.log` outputs should make more sense:
918919

920+
[role="skipme"]
919921
----
920922
lists.js loading lists.js:1:9
921923
Spec.js loading Spec.js:1:9
@@ -955,7 +957,7 @@ Oh dear, sure enough the tests just pass:
955957
[role="jasmine-output"]
956958
[subs="specialcharacters,quotes"]
957959
----
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
959961
960962
961963
Superlists tests
@@ -995,7 +997,7 @@ That gives us our expected failure:
995997
[role="jasmine-output"]
996998
[subs="specialcharacters,quotes"]
997999
----
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
9991001
10001002
Spec List | Failures
10011003
@@ -1129,7 +1131,7 @@ We've only refactored the tests so far, let's check they still pass:
11291131
[role="jasmine-output"]
11301132
[subs="specialcharacters,quotes"]
11311133
----
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
11331135
11341136
11351137
Superlists tests
@@ -1175,7 +1177,7 @@ Now we look at the tests:
11751177
[role="jasmine-output"]
11761178
[subs="specialcharacters,quotes"]
11771179
----
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
11791181
11801182
11811183
Superlists tests
@@ -1217,7 +1219,7 @@ And the tests still pass:
12171219
[role="jasmine-output"]
12181220
[subs="specialcharacters,quotes"]
12191221
----
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
12211223
----
12221224

12231225

@@ -1239,7 +1241,7 @@ Phew, that gives us a failure:
12391241
[role="jasmine-output"]
12401242
[subs="specialcharacters,quotes"]
12411243
----
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
12431245
12441246
Spec List | Failures
12451247
@@ -1253,7 +1255,7 @@ Expected true to be false.
12531255
Ok, back to the right way around:
12541256

12551257
[role="sourcecode"]
1256-
.src/lists/static/lists.js (ch16l026)
1258+
.src/lists/static/lists.js (ch16l027)
12571259
====
12581260
[source,javascript]
12591261
----
@@ -1281,7 +1283,7 @@ with the right selectors:
12811283
12821284
<script src="/static/lists.js"></script>
12831285
<script>
1284-
initialize("input#id_text", "div.invalid-feedback");
1286+
initialize("#id_text", ".invalid-feedback");
12851287
</script>
12861288
12871289
</body>
@@ -1356,7 +1358,7 @@ Oh dear, it seems like that doesn't quite work:
13561358
[role="jasmine-output"]
13571359
[subs="specialcharacters,quotes"]
13581360
----
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
13601362
13611363
Spec List | Failures
13621364
@@ -1398,7 +1400,7 @@ That gets us back to passing tests:
13981400
[role="jasmine-output"]
13991401
[subs="specialcharacters,quotes"]
14001402
----
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
14021404
14031405
14041406
Superlists tests

0 commit comments

Comments
 (0)