persist.spec.js 456 B

1234567891011121314151617
  1. import { haveText, html, test } from '../../utils'
  2. test('can perist data',
  3. [html`
  4. <div x-data="{ count: $persist(1) }">
  5. <button @click="count++">Inc</button>
  6. <span x-text="count"></span>
  7. </div>
  8. `],
  9. ({ get }, reload) => {
  10. get('span').should(haveText('1'))
  11. get('button').click()
  12. get('span').should(haveText('2'))
  13. reload()
  14. get('span').should(haveText('2'))
  15. },
  16. )