123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- import { beHidden, beVisible, haveText, beChecked, haveAttribute, haveClasses, haveValue, notBeChecked, notHaveAttribute, notHaveClasses, test, html } from '../../utils'
- test('style attribute object binding',
- html`
- <div x-data>
- <span x-bind:style="{ color: 'red' }">I should be red</span>
- </div>
- `,
- ({ get }) => {
- get('span').should(haveAttribute('style', 'color: red;'))
- }
- )
- test('style attribute object bindings are merged with existing styles',
- html`
- <div x-data>
- <span style="display: block" x-bind:style="{ color: 'red' }">I should be red</span>
- </div>
- `,
- ({ get }) => {
- get('span').should(haveAttribute('style', 'display: block; color: red;'))
- }
- )
- test('CSS custom properties are set',
- html`
- <div x-data="{custom_color: '#f00'}">
- <span style="color: var(--custom-prop)" x-bind:style="{ '--custom-prop': custom_color }">I should be red</span>
- </div>
- `,
- ({ get }) => {
- get('span').should(haveAttribute('style', 'color: var(--custom-prop); --custom-prop:#f00;'))
- }
- )
- test('existing CSS custom properties are preserved',
- html`
- <div x-data="{link: 'var(--custom-prop-a)'}">
- <span style="color: var(--custom-prop-b); --custom-prop-a: red" x-bind:style="{ '--custom-prop-b': link }">I should be red</span>
- </div>
- `,
- ({ get }) => {
- get('span').should(haveAttribute('style', 'color: var(--custom-prop-b); --custom-prop-a: red; --custom-prop-b:var(--custom-prop-a);'))
- }
- )
|