Skip to content

Commit 56a3867

Browse files
committed
Rewrite old browser.js into ui-test.js
1 parent 6f0c9f6 commit 56a3867

5 files changed

Lines changed: 314 additions & 288 deletions

File tree

.github/workflows/test.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ jobs:
1010
- run: npm audit --audit-level=low
1111
- run: npx c8 -r lcovonly -r text npm test
1212
- run: npx lj lint
13+
- name: Browser tests
14+
run: |
15+
npx lj serve &
16+
google-chrome --headless --virtual-time-budget=5000 --enable-logging=stderr http://127.0.0.1:8080/test/index.html 2>&1 | sed -n '/INFO:CONSOLE/s,.*"\(.*\)".*,\1,p' | tee /tmp/browser-test.txt
17+
grep -q "# pass" /tmp/browser-test.txt && ! grep -q "FAIL" /tmp/browser-test.txt
1318
- uses: coverallsapp/github-action@v2
1419
name: Upload to coveralls.io
1520
with:

browser.js

Lines changed: 0 additions & 288 deletions
This file was deleted.

test/index.html

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<!DOCTYPE html>
2+
<html lang="en"><head>
3+
<title>ui-test.js test</title>
4+
<meta name="viewport" content="initial-scale=1,maximum-scale=1">
5+
<link rel="icon" href="data:image/x-icon;,">
6+
<style>
7+
*, *:before, *:after { box-sizing: inherit }
8+
html { box-sizing: border-box; background: #eee }
9+
body { margin: 0 auto; max-width: 600px; padding: 18px; font: 18px/1.5 sans-serif }
10+
nav > a { margin-right: 16px }
11+
nav > a.is-sel { font-weight: bold }
12+
.count { font-size: 24px }
13+
</style>
14+
</head><body>
15+
<pre id=out></pre>
16+
<script type="ui">
17+
18+
%js
19+
El.$d.count = 0
20+
El.$d.inc = function() { El.$d.count++; El.render(document.body) }
21+
22+
%view #layout #
23+
header
24+
h1 Test App
25+
nav
26+
%el nav-link
27+
a ;cls "is-sel",url==($el.href.split("#")[1]||"home")
28+
nav-link[href="#"] Home
29+
nav-link[href="#about"] About
30+
nav-link[href="#counter"] Counter
31+
hr
32+
%slot
33+
footer
34+
hr
35+
p.info ;txt "Current: "+url
36+
37+
%view home #layout
38+
main
39+
h2 Welcome
40+
p This is the home page.
41+
42+
%view about #layout
43+
main
44+
h2 About
45+
p This is the about page.
46+
ul
47+
li Item A
48+
li Item B
49+
li Item C
50+
51+
%view counter #layout
52+
main
53+
h2 Counter
54+
p.count ;txt "Count: "+count
55+
button#btn-inc ;on "click",inc
56+
| Increment
57+
58+
%start
59+
60+
</script>
61+
<script src="https://litejs.com/litejs.full.min.js"></script>
62+
<script src="../test.js"></script>
63+
<script src="../ui-test.js"></script>
64+
<script>
65+
describe.onend = function() {
66+
out.textContent = describe.output
67+
}
68+
</script>
69+
<script src="ui-test.js"></script>
70+
<noscript>This application requires JavaScript</noscript>
71+
</body></html>

0 commit comments

Comments
 (0)