import * as assert from 'power-assert'
import { delay, minify } from './utils'
import { atto } from '../src/atto'
import { Context } from '../src/Context'
import { x } from '../src/x'
beforeEach(() => {
document.body.innerHTML = ''
})
test('Slice context', async () => {
const view = ({ xa: { context }, ...props }, children) => (
)
const Child: any = ({ xa: { context }, ...props }, children) => (
{context.name}
{context.children && context.children.length && (
)}
)
const Children: any = ({ xa: { context }, ...props }, children) => (
{context && context.length && context.map((_, i) => ( ))}
)
const mutate = atto(view, document.body)
mutate({
name: "foo",
children: [
{
name: "bar",
children: [
{
name: "bar child"
}
]
},
{
name: "baz",
children: [
{
name: "baz child"
}
]
}
]
})
await delay(10)
const html = minify`
`
assert(document.body.innerHTML == html)
})