Skip to content

Commit ea7bc2f

Browse files
committed
test(manual): add async failure test
1 parent 30c2789 commit ea7bc2f

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

test/manual/index.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@
4242
<p>Preloaded inlined CSS: Must be green.</p>
4343
<p><button class="preloaded-button2">Pressing this button</button> displays an alert and should turn red.</p>
4444
</div>
45+
<div class="test lazy-failure-css">
46+
<p>Lazy CSS: Turn off the network and <button class="lazy-failure-button">press this button</button>.</p>
47+
<p>An error should have appeared.</p>
48+
<p>Now if you turn the network back on and click it again, it should turn aqua.</p>
49+
</div>
4550
<div class="errors"></div>
4651
<script async defer src="/dist/main.js"></script>
4752
</body>

test/manual/src/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ const handleError = (err) => {
55
console.error(err);
66
}
77

8-
const makeButton = (className, fn) => {
8+
const makeButton = (className, fn, shouldDisable = true) => {
99
const button = document.querySelector(className);
1010
button.addEventListener("click", () => {
11-
button.disabled = true;
11+
if(shouldDisable) {
12+
button.disabled = true;
13+
}
1214
fn().then(() => {
1315
button.disabled = false;
1416
}).catch(handleError);
@@ -20,3 +22,5 @@ makeButton(".lazy-button2", () => import('./lazy2.css'));
2022

2123
makeButton(".preloaded-button1", () => import(/* webpackChunkName: "preloaded1" */ './preloaded1'));
2224
makeButton(".preloaded-button2", () => import(/* webpackChunkName: "preloaded2" */ './preloaded2'));
25+
26+
makeButton(".lazy-failure-button", () => import('./lazy-failure.js'), false);

test/manual/src/lazy-failure.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.lazy-failure-css {
2+
background: aqua;
3+
}

test/manual/src/lazy-failure.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './lazy-failure.css';

0 commit comments

Comments
 (0)