csp-compatibility.spec.js 563 B

12345678910111213141516171819202122
  1. import { haveText, html, test } from '../../utils'
  2. test.csp('Can use components and basic expressions with CSP-compatible build',
  3. [html`
  4. <div x-data="test">
  5. <span x-text="foo"></span>
  6. <button @click="change">Change Foo</button>
  7. </div>
  8. `,
  9. `
  10. Alpine.data('test', () => ({
  11. foo: 'bar',
  12. change() { this.foo = 'baz' },
  13. }))
  14. `],
  15. ({ get }) => {
  16. get('span').should(haveText('bar'))
  17. get('button').click()
  18. get('span').should(haveText('baz'))
  19. }
  20. )