12345678910111213141516171819202122232425262728293031323334353637 |
- import { haveText, notHaveText, html, test } from '../../utils'
- test('sets html on init',
- html`
- <div x-data="{ foo: '<h1>hey</h1>' }">
- <span x-html="foo"></span>
- </div>
- `,
- ({ get }) => {
- get('h1').should(haveText('hey'))
- }
- )
- test('sets html on update',
- html`
- <div x-data="{ foo: '' }">
- <button x-on:click="foo = '<h1>hey</h1>'">Show "bar"</button>
- <span x-html="foo"></span>
- </div>
- `,
- ({ get }) => {
- get('span').should(notHaveText('hey'))
- get('button').click()
- get('h1').should(haveText('hey'))
- }
- )
- test('x-html allows alpine code within',
- html`
- <div x-data="{ foo: '<h1 x-text="bar"></h1>', bar: 'baz' }" x-html="foo"></div>
- `,
- ({ get }) => {
- get('h1').should(haveText('baz'))
- }
- )
|