Skip to content

Commit

Permalink
tests: add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
barelyhuman committed Jan 26, 2024
1 parent 243267d commit f495973
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/basic.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { test } from 'uvu'
import * as assert from 'uvu/assert'
import { html, reactive } from '@arrow-js/core'

import { renderToString } from '../src/index.js'
import { inlineSnapshot } from 'uvu-inline-snapshot'

Expand Down Expand Up @@ -241,4 +242,30 @@ test('stringify nested array of templates', async () => {
)
})

test('reactive class attribute', async () => {
const state = reactive({ count: 0 })

const comp = html`<div class="${() => (state.count > 10 ? 'active' : '')}">
Hello
</div>`

const nonClass = renderToString(comp)
state.count = 11
const withClass = renderToString(comp)

await inlineSnapshot(
nonClass,
`<div class="">
Hello
</div>`
)

await inlineSnapshot(
withClass,
`<div class="active">
Hello
</div>`
)
})

test.run()
30 changes: 30 additions & 0 deletions tests/composability.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f495973

Please sign in to comment.