import { haveText, test, html } from '../../utils'
test('can intersect',
[html`
`],
({ get }) => {
get('span').should(haveText('0'))
get('#1').scrollIntoView({duration: 100})
get('span').should(haveText('1'))
get('span').scrollIntoView({duration: 100})
get('span').should(haveText('1'))
get('#1').scrollIntoView({duration: 100})
get('span').should(haveText('2'))
},
)
test('It should evaluate with ":enter" only when the component is intersected',
[html`
`],
({ get }) => {
get('span').should(haveText('0'))
get('#1').scrollIntoView({duration: 100})
get('span').should(haveText('1'))
get('span').scrollIntoView({duration: 100})
get('span').should(haveText('1'))
get('#1').scrollIntoView({duration: 100})
get('span').should(haveText('2'))
},
)
test('It should evaluate with ":leave" only when the component is not intersected',
[html`
`],
({ get }) => {
get('span').should(haveText('1'))
get('#1').scrollIntoView({duration: 100})
get('span').should(haveText('1'))
get('span').scrollIntoView({duration: 100})
get('span').should(haveText('2'))
get('#1').scrollIntoView({duration: 100})
get('span').should(haveText('2'))
get('span').scrollIntoView({duration: 100})
get('span').should(haveText('3'))
},
)
test('.half',
[html`
`],
({ get }) => {
get('span').should(haveText('0'))
get('#container').scrollTo(0, 100, {duration: 100})
get('span').should(haveText('0'))
get('#container').scrollTo(0, 210, {duration: 100})
get('span').should(haveText('1'))
},
)
test('.full',
[html`
`],
({ get }) => {
get('span').should(haveText('0'))
get('#container').scrollTo(0, 200, {duration: 100})
get('span').should(haveText('0'))
get('#container').scrollTo(0, 400, {duration: 100})
get('span').should(haveText('1'))
},
)
test('.once',
[html`
`],
({ get }) => {
get('span').should(haveText('0'))
get('#1').scrollIntoView({duration: 100})
get('span').should(haveText('1'))
get('span').scrollIntoView({duration: 100})
get('span').should(haveText('1'))
get('#1').scrollIntoView({duration: 100})
get('span').should(haveText('2'))
},
)
test('.margin',
[html`
`],
({ get }) => {
get('span').should(haveText('0'))
get('#buffer-top').scrollIntoView({duration: 100})
get('span').should(haveText('1'))
get('#1').scrollIntoView({duration: 100})
get('span').should(haveText('1'))
get('span').scrollIntoView({duration: 100})
get('span').should(haveText('1'))
get('#buffer-top').scrollIntoView({duration: 100})
get('span').should(haveText('2'))
get('#1').scrollIntoView({duration: 100})
get('span').should(haveText('2'))
},
)
test('.threshold',
[html`
`],
({ get }) => {
get('span').should(haveText('0'))
get('#1').click()
get('span').should(haveText('0'))
get('#2').click()
get('span').should(haveText('1'))
},
)