import { exist, haveText, html, notExist, test } from '../../utils'
test('can use a x-teleport',
[html`
`],
({ get }) => {
get('#b span').should(haveText('1'))
get('button').click()
get('#b span').should(haveText('2'))
},
)
test('can use a x-teleport.append',
[html`
`],
({ get }) => {
get('#b + span').should(haveText('1'))
get('button').click()
get('#b + span').should(haveText('2'))
},
)
test('can use a x-teleport.prepend',
[html`
`],
({ get }) => {
get('#a + span').should(haveText('1'))
get('button').click()
get('#a + span').should(haveText('2'))
},
)
test('can teleport multiple',
[html`
`],
({ get }) => {
get('#b h1').should(haveText('1'))
get('#b h2').should(haveText('2'))
get('button').click()
get('#b h1').should(haveText('2'))
get('#b h2').should(haveText('3'))
},
)
test('teleported targets forward events to teleport source if listeners are attached',
[html`
`],
({ get }) => {
get('#b h1').should(haveText('1'))
get('button').click()
get('#b h1').should(haveText('2'))
get('h1').click()
get('#b h1').should(haveText('3'))
},
)
test('removing teleport source removes teleported target',
[html`
`],
({ get }) => {
get('#b h1').should(exist())
get('button').click()
get('#b h1').should(notExist())
},
)
test('$refs inside teleport can be accessed outside',
[html`
`],
({ get }) => {
get('#b h1').should(exist())
get('button').click()
get('#b h1').should(notExist())
},
)
test('$root is accessed outside teleport',
[html`
`],
({ get }) => {
get('#b h1').should(exist())
get('#b h1').should(haveText('a'))
},
)
test('$id honors x-id outside teleport',
[html`
`],
({ get }) => {
get('#b h1').should(haveText('foo-1'))
},
)