Skip to content

Commit d508ec1

Browse files
committed
test: for issue, #57
1 parent cc165f0 commit d508ec1

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<p>x</p>
2+
3+
4+
<a class="selected" href="/page1">Page 1</a>
5+
6+
7+
<a href="/page2">Page 2</a>
8+
9+
10+
<a href="/page3">Page 3</a>
11+
12+
<p>x</p>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<p>x</p>
2+
<each loop="page in pages">
3+
<if condition="page.path === current_path">
4+
<a class="selected" href="{{ page.path }}">{{ page.title }}</a>
5+
</if>
6+
<else>
7+
<a href="{{ page.path }}">{{ page.title }}</a>
8+
</else>
9+
</each>
10+
<p>x</p>

test/test-loops.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function process (t, name, options, log = false) {
2323
return clean(result.html)
2424
})
2525
.then((html) => {
26-
t.truthy(html === expect(name).trim())
26+
t.is(html, expect(name).trim())
2727
})
2828
}
2929

@@ -65,6 +65,19 @@ test('Loops - conditional included', (t) => {
6565
})
6666
})
6767

68+
test('Loops - conditional and locals included', (t) => {
69+
return process(t, 'loop_conditional_locals', {
70+
locals: {
71+
pages: [
72+
{ path: "/page1", title: "Page 1" },
73+
{ path: "/page2", title: "Page 2" },
74+
{ path: "/page3", title: "Page 3" }
75+
],
76+
current_path: '/page1'
77+
}
78+
})
79+
})
80+
6881
test('Loops - conflicting locals', (t) => {
6982
return process(t, 'loop_conflict', {
7083
locals: { items: [1, 2, 3], item: 'bar' }

0 commit comments

Comments
 (0)