import { beHidden, beVisible, haveText, beChecked, haveAttribute, haveClasses, haveValue, notBeChecked, notHaveAttribute, notHaveClasses, test, html } from '../../utils' test('sets attribute bindings on initialize', html`
[Subject]
`, ({ get }) => get('span').should(haveAttribute('foo', 'bar')) ) test('sets undefined nested keys to empty string', html`
`, ({ get }) => get('span').should(haveAttribute('foo', '')) ) test('style attribute bindings are added by string syntax', html`
`, ({ get }) => get('span').should(haveClasses(['foo'])) ) test('aria-pressed/checked attribute boolean values are cast to a true/false string', html`
`, ({ get }) => get('span').should(haveAttribute('aria-pressed', 'true')) ) test('non-boolean attributes set to null/undefined/false are removed from the element', html`
null false undefined null false undefined
`, ({ get }) => { get('a:nth-child(1)').should(notHaveAttribute('href')) get('a:nth-child(2)').should(notHaveAttribute('href')) get('a:nth-child(3)').should(notHaveAttribute('href')) get('span:nth-child(1)').should(notHaveAttribute('visible')) get('span:nth-child(2)').should(notHaveAttribute('visible')) get('span:nth-child(3)').should(notHaveAttribute('visible')) } ) test('non-boolean empty string attributes are not removed', html`
`, ({ get }) => get('a').should(haveAttribute('href', '')) ) test('boolean attribute values are set to their attribute name if true and removed if false', html`
Set To False
    `, ({ get }) => { get('input:nth-of-type(1)').should(haveAttribute('disabled', 'disabled')) get('input:nth-of-type(2)').should(haveAttribute('checked', 'checked')) get('input:nth-of-type(3)').should(haveAttribute('required', 'required')) get('input:nth-of-type(4)').should(haveAttribute('readonly', 'readonly')) get('details').should(haveAttribute('open', 'open')) get('select').should(haveAttribute('multiple', 'multiple')) get('option').should(haveAttribute('selected', 'selected')) get('textarea').should(haveAttribute('autofocus', 'autofocus')) get('dl').should(haveAttribute('itemscope', 'itemscope')) get('form').should(haveAttribute('novalidate', 'novalidate')) get('iframe').should(haveAttribute('allowfullscreen', 'allowfullscreen')) get('iframe').should(haveAttribute('allowpaymentrequest', 'allowpaymentrequest')) get('button').should(haveAttribute('formnovalidate', 'formnovalidate')) get('audio').should(haveAttribute('autoplay', 'autoplay')) get('audio').should(haveAttribute('controls', 'controls')) get('audio').should(haveAttribute('loop', 'loop')) get('audio').should(haveAttribute('muted', 'muted')) get('video').should(haveAttribute('playsinline', 'playsinline')) get('track').should(haveAttribute('default', 'default')) get('img').should(haveAttribute('ismap', 'ismap')) get('ol').should(haveAttribute('reversed', 'reversed')) get('#setToFalse').click() get('input:nth-of-type(1)').should(notHaveAttribute('disabled')) get('input:nth-of-type(2)').should(notHaveAttribute('checked')) get('input:nth-of-type(3)').should(notHaveAttribute('required')) get('input:nth-of-type(4)').should(notHaveAttribute('readonly')) get('details').should(notHaveAttribute('open')) get('select').should(notHaveAttribute('multiple')) get('option').should(notHaveAttribute('selected')) get('textarea').should(notHaveAttribute('autofocus')) get('dl').should(notHaveAttribute('itemscope')) get('form').should(notHaveAttribute('novalidate')) get('iframe').should(notHaveAttribute('allowfullscreen')) get('iframe').should(notHaveAttribute('allowpaymentrequest')) get('button').should(notHaveAttribute('formnovalidate')) get('audio').should(notHaveAttribute('autoplay')) get('audio').should(notHaveAttribute('controls')) get('audio').should(notHaveAttribute('loop')) get('audio').should(notHaveAttribute('muted')) get('video').should(notHaveAttribute('playsinline')) get('track').should(notHaveAttribute('default')) get('img').should(notHaveAttribute('ismap')) get('ol').should(notHaveAttribute('reversed')) get('script').should(notHaveAttribute('async')) get('script').should(notHaveAttribute('defer')) get('script').should(notHaveAttribute('nomodule')) } ) test('boolean empty string attributes are not removed', html`
    `, ({ get }) => get('input').should(haveAttribute('disabled', 'disabled')) ) test('binding supports short syntax', html`
    `, ({ get }) => get('span').should(haveClasses(['bar'])) ) test('checkbox is unchecked by default', html`
    `, ({ get }) => { get('input:nth-of-type(1)').should(notBeChecked()) get('input:nth-of-type(2)').should(notBeChecked()) get('input:nth-of-type(3)').should(notBeChecked()) get('input:nth-of-type(4)').should(notBeChecked()) get('input:nth-of-type(5)').should(notBeChecked()) } ) test('radio is unchecked by default', html`
    `, ({ get }) => { get('input:nth-of-type(1)').should(notBeChecked()) get('input:nth-of-type(2)').should(notBeChecked()) get('input:nth-of-type(3)').should(notBeChecked()) get('input:nth-of-type(4)').should(notBeChecked()) get('input:nth-of-type(5)').should(notBeChecked()) } ) test('checkbox values are set correctly', html`
    `, ({ get }) => { get('input:nth-of-type(1)').should(haveValue('foo')) get('input:nth-of-type(2)').should(haveValue('on')) get('input:nth-of-type(3)').should(haveValue('on')) } ) test('radio values are set correctly', html`
    `, ({ get }) => { get('#list-1').should(haveValue('1')) get('#list-1').should(notBeChecked()) get('#list-8').should(haveValue('8')) get('#list-8').should(beChecked()) get('#list-test').should(haveValue('test')) get('#list-test').should(notBeChecked()) } ) test('.camel modifier correctly sets name of attribute', html`
    `, ({ get }) => get('svg').should(haveAttribute('viewBox', '0 0 42 42')) ) test('attribute binding names can contain numbers', html` `, ({ get }) => { get('line').should(haveAttribute('x2', '3')) get('line').should(haveAttribute('y2', '4')) } ) test('non-string and non-boolean attributes are cast to string when bound to checkbox', html`
    `, ({ get }) => { get('input:nth-of-type(1)').should(haveValue('100')) get('input:nth-of-type(2)').should(haveValue('0')) get('input:nth-of-type(3)').should(haveValue('on')) get('input:nth-of-type(4)').should(haveValue('on')) } ) test('can bind an object of directives', html`
    Modal Body
    `, ({ get }) => { get('span').should(haveText('bar')) get('button').click() get('span').should(haveText('baz')) } ) test('x-bind object syntax supports normal HTML attributes', html` `, ({ get }) => { get('span').should(haveAttribute('foo', 'bar')) } ) test('x-bind object syntax supports x-for', html`
    `, ({ get }) => { get('li:nth-of-type(1)').should(haveText('foo')) get('li:nth-of-type(2)').should(haveText('bar')) } ) test('x-bind object syntax syntax supports x-transition', html`
    thing
    `, ({ get }) => { get('span').should(beVisible()) get('button').click() get('span').should(beVisible()) get('span').should(beHidden()) } ) test('x-bind object syntax event handlers defined as functions receive the event object as their first argument', html`
    foo
    `, ({ get }) => { get('span').should(haveText('foo')) get('button').click() get('span').should(haveText('bar')) } )