import { beChecked, haveData, haveText, haveValue, html, notBeChecked, test } from '../../utils' test('The name of the test', html`

`, ({ get }) => get('h1').should(haveText('HEY')) ) test('x-model has value binding when initialized', html`
`, ({ get }) => { get('input').should(haveValue('bar')) } ) test('x-model updates value when updated via input event', html`
`, ({ get }) => { get('span').should(haveText('bar')) get('input').type('baz') get('span').should(haveText('barbaz')) } ) test('x-model has value binding when updated', html`
`, ({ get }) => { get('input').should(haveValue('bar')) get('button').click() get('input').should(haveValue('baz')) } ) test('x-model casts value to number if number modifier is present', html`
`, ({ get }) => { get('input').type('123') get('div').should(haveData('foo', 123)) } ) test('x-model with number modifier returns: null if empty, original value if casting fails, numeric value if casting passes', html`
`, ({ get }) => { get('input:nth-of-type(1)').clear() get('div').should(haveData('foo', null)) get('input:nth-of-type(1)').clear().type('-') get('div').should(haveData('foo', null)) get('input:nth-of-type(1)').clear().type('-123') get('div').should(haveData('foo', -123)) get('input:nth-of-type(2)').type(123).clear() get('div').should(haveData('bar', null)) get('input:nth-of-type(2)').clear().type('-') get('div').should(haveData('bar', '-')) get('input:nth-of-type(2)').clear().type('-123') get('div').should(haveData('bar', -123)) } ) test('x-model casts value to boolean initially for radios', html`
`, ({ get }) => { get('div').should(haveData('foo', true)) get('#1').should(beChecked()) get('#2').should(notBeChecked()) get('#2').click() get('div').should(haveData('foo', false)) get('#1').should(notBeChecked()) get('#2').should(beChecked()) } ) test('x-model casts value to boolean if boolean modifier is present', html`
`, ({ get }) => { get('input[type=text]').type('1') get('div').should(haveData('foo', true)) get('input[type=text]').clear().type('0') get('div').should(haveData('foo', false)) get('input[type=checkbox]').check() get('div').should(haveData('foo', true)) get('input[type=checkbox]').uncheck() get('div').should(haveData('foo', false)) get('input[type=radio][value="true"]').should(notBeChecked()) get('input[type=radio][value="false"]').should(beChecked()) get('input[type=radio][value="true"]').check() get('div').should(haveData('foo', true)) get('input[type=radio][value="false"]').check() get('div').should(haveData('foo', false)) get('select').select('false') get('div').should(haveData('bar', false)) get('select').select('true') get('div').should(haveData('bar', true)) } ) test('x-model with boolean modifier returns: null if empty, original value if casting fails, numeric value if casting passes', html`
`, ({ get }) => { get('input').clear() get('div').should(haveData('foo', null)) get('input').clear().type('bar') get('div').should(haveData('foo', true)) get('input').clear().type('1') get('div').should(haveData('foo', true)) get('input').clear().type('1').clear() get('div').should(haveData('foo', null)) get('input').clear().type('0') get('div').should(haveData('foo', false)) get('input').clear().type('bar') get('div').should(haveData('foo', true)) get('input').clear().type('0').clear() get('div').should(haveData('foo', null)) } ) test('x-model trims value if trim modifier is present', html`
`, ({ get }) => { get('input').type('bar ') get('div').should(haveData('foo', 'bar')) } ) test('x-model can be accessed programmatically', html`
`, ({ get }) => { get('span').should(haveText('bar')) get('input').type('baz') get('span').should(haveText('barbaz')) get('button').click() get('span').should(haveText('bob')) } ) test('x-model updates value when the form is reset', html`
`, ({ get }) => { get('span').should(haveText('')) get('input').type('baz') get('span').should(haveText('baz')) get('button').click() get('span').should(haveText('')) } ) test('x-model with fill modifier takes input value on null, empty string or undefined', html`
`, ({ get }) => { get('#a').should(haveText('123')) get('#b').should(haveText('0')) get('#c').should(haveText('123456')) get('#d').should(haveText('123456')) get('#e').should(haveText('123456')) } ) test('x-model with fill modifier works with select elements', html`
`, ({ get }) => { get('[x-data]').should(haveData('a', '456')); get('[x-data]').should(haveData('b', ['123', '456'])); } ); test('x-model with fill modifier works with radio elements', html`
`, ({ get }) => { get('[x-data]').should(haveData('a', '456')); get('[x-data]').should(haveData('b', '789')); get('[x-data]').should(haveData('c', '101112')); } ); test('x-model with fill modifier respects number modifier', html`
`, ({ get }) => { get('[x-data]').should(haveData('a', 456)); get('[x-data]').should(haveData('b', [123,456])); } ); test( 'x-model with fill applies on checkboxes bound to array', html`
`, ({ get }) => { get('[x-data]').should(haveData('a', ['123'])); } ); test( 'x-model with fill and debounce still fills value', html`
`, ({ get }) => { get('[x-data]').should(haveData('a', 'hello')); } );