x-if.spec.js 530 B

1234567891011121314151617181920
  1. import { beVisible, html, notBeVisible, notHaveAttribute, test } from '../../utils'
  2. test('x-if',
  3. html`
  4. <div x-data="{ show: false }">
  5. <button @click="show = ! show">Toggle</button>
  6. <template x-if="show">
  7. <h1>Toggle Me</h1>
  8. </template>
  9. </div>
  10. `,
  11. ({ get }) => {
  12. get('h1').should(notBeVisible())
  13. get('button').click()
  14. get('h1').should(beVisible())
  15. get('button').click()
  16. get('h1').should(notBeVisible())
  17. }
  18. )