collapse.spec.js 621 B

1234567891011121314151617
  1. import { haveAttribute, haveComputedStyle, html, test } from '../../utils'
  2. test('can collapse and expand element',
  3. [html`
  4. <div x-data="{ expanded: false }">
  5. <button @click="expanded = ! expanded">toggle</button>
  6. <h1 x-show="expanded" x-collapse>contents</h1>
  7. </div>
  8. `],
  9. ({ get }, reload) => {
  10. get('h1').should(haveComputedStyle('height', '0px'))
  11. get('button').click()
  12. get('h1').should(haveAttribute('style', 'overflow: hidden; height: auto;'))
  13. get('button').click()
  14. get('h1').should(haveComputedStyle('height', '0px'))
  15. },
  16. )