import { haveText, html, test } from '../../utils'
test('can go back and forth',
[html`
`],
({ get, url, go }) => {
get('span').should(haveText('1'))
url().should('include', '?count=1')
get('button').click()
get('span').should(haveText('2'))
url().should('include', '?count=2')
go('back')
get('span').should(haveText('1'))
url().should('include', '?count=1')
go('forward')
get('span').should(haveText('2'))
url().should('include', '?count=2')
},
)
test('property is set from the query string on load',
[html`
`],
({ get, url }, reload) => {
get('span').should(haveText('1'))
url().should('include', '?count=1')
get('button').click()
get('span').should(haveText('2'))
url().should('include', '?count=2')
reload()
get('span').should(haveText('2'))
},
)
test('can use a query string key alias',
[html`
`],
({ get, url }, reload) => {
get('span').should(haveText('1'))
url().should('include', '?foo=1')
get('button').click()
get('span').should(haveText('2'))
url().should('include', '?foo=2')
reload()
get('span').should(haveText('2'))
},
)
test('can go back and forth with multiple components',
[html`
`],
({ get, url, go }) => {
get('#foo span').should(haveText('1'))
url().should('include', 'foo=1')
get('#foo button').click()
get('#foo span').should(haveText('2'))
url().should('include', 'foo=2')
get('#bar span').should(haveText('1'))
url().should('include', 'bar=1')
get('#bar button').click()
get('#bar span').should(haveText('2'))
url().should('include', 'bar=2')
go('back')
get('#bar span').should(haveText('1'))
url().should('include', 'bar=1')
get('#foo span').should(haveText('2'))
url().should('include', 'foo=2')
go('back')
get('#bar span').should(haveText('1'))
url().should('include', 'bar=1')
get('#foo span').should(haveText('1'))
url().should('include', 'foo=1')
},
)