Skip to content

Commit 3499e07

Browse files
authored
Merge pull request #12 from jonsmithers/write-tests-and-clean-up-indentation
Write tests and clean up indentation code
2 parents 84dcc75 + 7cb3dcc commit 3499e07

8 files changed

+398
-293
lines changed

after/indent/javascript.vim

Lines changed: 112 additions & 201 deletions
Large diffs are not rendered by default.

test/lit-html.vader renamed to test/example-code-tests/example-code-tests.vader

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
" This test file is not used for regular testing because the tests here are
2+
" generally very large in scope and thus not helpful in telling you what's
3+
" actually failing.
4+
15
Before:
26
set tabstop=2
37
set shiftwidth=2
@@ -285,3 +289,81 @@ Expect javascript:
285289
" ${items.map((i) => html`<li>${i}</li>`)}
286290
" </ul>
287291
" `;
292+
293+
294+
Before:
295+
set tabstop=2
296+
set shiftwidth=2
297+
set expandtab
298+
299+
Given javascript (multiple syntaxes on one line);
300+
return html`<style>.mood { color: green; }</style>
301+
Web Components are
302+
<span class="mood">${mood}</span>!`;
303+
304+
Do:
305+
=G
306+
307+
Expect javascript;
308+
return html`<style>.mood { color: green; }</style>
309+
Web Components are
310+
<span class="mood">${mood}</span>!`;
311+
312+
Given javascript (tricky indnetation);
313+
return html`
314+
<div> Files </div>
315+
${!this.fileList ?
316+
html`
317+
<paper-button on-click=${() => this.onFetchBtn()}>
318+
fetch notes
319+
</paper-button>
320+
` : html`
321+
<paper-button on-click=${() => this.onFetchBtn()}>
322+
refresh
323+
</paper-button>
324+
${repeat(this.fileList || [], null, (file) => html`
325+
<paper-item on-click=${() => this.onFileClick(file.path)} data="${file}">${file.name}</paper-item>
326+
`)}
327+
`}
328+
<style>
329+
paper-fab#newFile {
330+
position: fixed;
331+
right: 20px;
332+
bottom: 20px;
333+
background-color: red;
334+
}
335+
</style>
336+
<paper-fab icon="add" id="newFile" on-click=${()=>this.onNewFileClick()}></paper-fab>
337+
`;
338+
339+
Do:
340+
=G
341+
342+
Expect javascript;
343+
return html`
344+
<div> Files </div>
345+
${!this.fileList ?
346+
html`
347+
<paper-button on-click=${() => this.onFetchBtn()}>
348+
fetch notes
349+
</paper-button>
350+
` : html`
351+
<paper-button on-click=${() => this.onFetchBtn()}>
352+
refresh
353+
</paper-button>
354+
${repeat(this.fileList || [], null, (file) => html`
355+
<paper-item on-click=${() => this.onFileClick(file.path)} data="${file}">${file.name}</paper-item>
356+
`)}
357+
`}
358+
<style>
359+
paper-fab#newFile {
360+
position: fixed;
361+
right: 20px;
362+
bottom: 20px;
363+
background-color: red;
364+
}
365+
</style>
366+
<paper-fab icon="add" id="newFile" on-click=${()=>this.onNewFileClick()}></paper-fab>
367+
`;
368+
369+
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
Before:
2+
set tabstop=2
3+
set shiftwidth=2
4+
set expandtab
5+
6+
" (IT SHOULD CORRECTLY INDENT...)
7+
Given javascript (LITERAL WITH SINGLE NEWLINE);
8+
{
9+
html`
10+
`;
11+
}
12+
13+
Do:
14+
=G
15+
16+
Expect javascript;
17+
{
18+
html`
19+
`;
20+
}
21+
22+
Given javascript (LITERAL WITH SINGLE HTML TAG);
23+
{
24+
html`
25+
<div></div>
26+
`;
27+
}
28+
29+
Do:
30+
=G
31+
32+
Expect javascript;
33+
{
34+
html`
35+
<div></div>
36+
`;
37+
}
38+
39+
40+
Given javascript (LITERAL WITH SINGLE SELF CLOSING TAG);
41+
{
42+
html`
43+
<img />
44+
`;
45+
}
46+
47+
Do:
48+
=G
49+
50+
Expect javascript;
51+
{
52+
html`
53+
<img />
54+
`;
55+
}
56+
57+
Given javascript (LITERAL AT END OF LINE, NO SEMICOLON);
58+
{
59+
html`
60+
<div>
61+
</div>`
62+
more()
63+
}
64+
65+
Do:
66+
=G
67+
68+
Expect javascript;
69+
{
70+
html`
71+
<div>
72+
</div>`
73+
more()
74+
}
75+
76+
Given javascript (LITERAL AT END OF LINE, WITH SEMICOLON);
77+
{
78+
html`
79+
<div>
80+
</div>`;
81+
more()
82+
}
83+
84+
Do:
85+
=G
86+
87+
Expect javascript;
88+
{
89+
html`
90+
<div>
91+
</div>`;
92+
more()
93+
}
94+
95+
Given javascript (LITERAL AT END OF ONLY LINE);
96+
{
97+
html`
98+
<div></div>`
99+
more()
100+
}
101+
102+
Do:
103+
=G
104+
105+
Expect javascript;
106+
{
107+
html`
108+
<div></div>`
109+
more()
110+
}
111+
112+
Given javascript (NEXT LINE AFTER LITERAL);
113+
{
114+
html`
115+
${
116+
html`
117+
<div></div>` } `;
118+
more()
119+
}
120+
121+
Do:
122+
=G
123+
124+
Expect javascript;
125+
{
126+
html`
127+
${
128+
html`
129+
<div></div>` } `;
130+
more()
131+
}
132+
133+
After:
134+
# Given javascript (IGNORED: LITERAL AFTER SELF-CLOSING TAG)
135+
# {
136+
# html`
137+
# <div/>
138+
# `;
139+
# }
140+
#
141+
# Do:
142+
# =G
143+
#
144+
# Expect javascript;
145+
# {
146+
# html`
147+
# <div/>
148+
# `;
149+
# }
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
" (IT SHOULD CORRECTLY INDENT...)
3+
Given javascript (COMMENTED TEMPLATES):
4+
// html`
5+
// <div></div>`;
6+
7+
Do:
8+
=G
9+
10+
Expect javascript:
11+
// html`
12+
// <div></div>`;

test/indent/template-end.vader

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Before:
2+
set tabstop=2
3+
set shiftwidth=2
4+
set expandtab
5+
6+
" (IT SHOULD CORRECTLY INDENT...)
7+
Given javascript (NEXT LINE OF HTML);
8+
{
9+
html`
10+
${
11+
html`${
12+
2 + 2}`}
13+
<div>
14+
</div>
15+
`;
16+
}
17+
18+
Do:
19+
=G
20+
21+
Expect javascript;
22+
{
23+
html`
24+
${
25+
html`${
26+
2 + 2}`}
27+
<div>
28+
</div>
29+
`;
30+
}

test/minimalvimrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,11 @@ call plug#begin('~/.vim/plugged')
55
Plug 'pangloss/vim-javascript'
66
call plug#end()
77
syntax enable
8+
let g:VHTL_debugging = 1
89
let g:html_indent_style1 = "inc"
10+
11+
nmap <F10> :echo map(synstack(line("."), col(".")), "synIDattr(v:val, 'name')")<cr>
12+
13+
set tabstop=2
14+
set shiftwidth=2
15+
set expandtab

test/random-examples.vader

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

test/runtests

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,9 @@
22

33
cd "$(dirname "$0")"
44

5-
vim -u <(cat minimalvimrc) +Vader*
5+
if [[ "$CI" = true ]]; then
6+
export VADER_OUTPUT_FILE='testresults.txt'
7+
vim -u <(cat minimalvimrc) +'Vader! indent/*.vader'
8+
else
9+
vim -u <(cat minimalvimrc) +'Vader indent/*.vader'
10+
fi

0 commit comments

Comments
 (0)