Skip to content

Commit

Permalink
test: add test for array use case
Browse files Browse the repository at this point in the history
  • Loading branch information
Raynos committed Sep 2, 2020
1 parent 86e7a7b commit 30fb698
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,28 @@ test('Tonic escapes text', t => {
t.end()
})

test('Tonic supports array of templates', t => {
class Comp1 extends Tonic {
render () {
const options = []
for (const o of ['one', 'two', 'three']) {
options.push(this.html`
<option value="${o}">${o}</option>
`)
}

return this.html`<select>${options}</select>`
}
}
const compName = `x-${uuid()}`
Tonic.add(Comp1, compName)

document.body.innerHTML = `<${compName}></${compName}>`
const options = document.body.querySelectorAll('option')
t.equal(options.length, 3)
t.end()
})

test('Tonic escapes attribute injection', t => {
class Comp1 extends Tonic {
render () {
Expand Down

0 comments on commit 30fb698

Please sign in to comment.