X-Git-Url: https://git.cyclocoop.org/%242?a=blobdiff_plain;f=tests%2Fqunit%2Fsuites%2Fresources%2Fjquery%2Fjquery.placeholder.test.js;h=5d0ddebb9828d69d15914e2ba5e635ab39503b91;hb=32d052537191da40afcd3d50f1f93cdba34db463;hp=78c185f1080f149fdd5b877b58990b3b563a3384;hpb=4ac9dbee4a1c0688da6dfa91e8c6419c1bd16f69;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/qunit/suites/resources/jquery/jquery.placeholder.test.js b/tests/qunit/suites/resources/jquery/jquery.placeholder.test.js index 78c185f108..5d0ddebb98 100644 --- a/tests/qunit/suites/resources/jquery/jquery.placeholder.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.placeholder.test.js @@ -1,13 +1,13 @@ -( function ($) { +( function ( $ ) { - QUnit.module('jquery.placeholder', QUnit.newMwEnvironment()); + QUnit.module( 'jquery.placeholder', QUnit.newMwEnvironment() ); - QUnit.test('caches results of feature tests', 2, function (assert) { - assert.strictEqual( typeof $.fn.placeholder.input, 'boolean', '$.fn.placeholder.input'); - assert.strictEqual( typeof $.fn.placeholder.textarea, 'boolean', '$.fn.placeholder.textarea'); - }); + QUnit.test( 'caches results of feature tests', 2, function ( assert ) { + assert.strictEqual( typeof $.fn.placeholder.input, 'boolean', '$.fn.placeholder.input' ); + assert.strictEqual( typeof $.fn.placeholder.textarea, 'boolean', '$.fn.placeholder.textarea' ); + } ); - if ($.fn.placeholder.input && $.fn.placeholder.textarea) { + if ( $.fn.placeholder.input && $.fn.placeholder.textarea ) { return; } @@ -20,126 +20,126 @@ '' + '' + '', - testElement = function ($el, assert) { + testElement = function ( $el, assert ) { - var el = $el[0], - placeholder = el.getAttribute('placeholder'); + var el = $el[ 0 ], + placeholder = el.getAttribute( 'placeholder' ); - assert.strictEqual($el.placeholder(), $el, 'should be chainable'); + assert.strictEqual( $el.placeholder(), $el, 'should be chainable' ); - assert.strictEqual(el.value, placeholder, 'should set `placeholder` text as `value`'); - assert.strictEqual($el.prop('value'), '', 'propHooks works properly'); - assert.strictEqual($el.val(), '', 'valHooks works properly'); - assert.ok($el.hasClass('placeholder'), 'should have `placeholder` class'); + assert.strictEqual( el.value, placeholder, 'should set `placeholder` text as `value`' ); + assert.strictEqual( $el.prop( 'value' ), '', 'propHooks works properly' ); + assert.strictEqual( $el.val(), '', 'valHooks works properly' ); + assert.ok( $el.hasClass( 'placeholder' ), 'should have `placeholder` class' ); // test on focus $el.focus(); - assert.strictEqual(el.value, '', '`value` should be the empty string on focus'); - assert.strictEqual($el.prop('value'), '', 'propHooks works properly'); - assert.strictEqual($el.val(), '', 'valHooks works properly'); - assert.ok(!$el.hasClass('placeholder'), 'should not have `placeholder` class on focus'); + assert.strictEqual( el.value, '', '`value` should be the empty string on focus' ); + assert.strictEqual( $el.prop( 'value' ), '', 'propHooks works properly' ); + assert.strictEqual( $el.val(), '', 'valHooks works properly' ); + assert.ok( !$el.hasClass( 'placeholder' ), 'should not have `placeholder` class on focus' ); // and unfocus (blur) again $el.blur(); - assert.strictEqual(el.value, placeholder, 'should set `placeholder` text as `value`'); - assert.strictEqual($el.prop('value'), '', 'propHooks works properly'); - assert.strictEqual($el.val(), '', 'valHooks works properly'); - assert.ok($el.hasClass('placeholder'), 'should have `placeholder` class'); + assert.strictEqual( el.value, placeholder, 'should set `placeholder` text as `value`' ); + assert.strictEqual( $el.prop( 'value' ), '', 'propHooks works properly' ); + assert.strictEqual( $el.val(), '', 'valHooks works properly' ); + assert.ok( $el.hasClass( 'placeholder' ), 'should have `placeholder` class' ); // change the value - $el.val('lorem ipsum'); - assert.strictEqual($el.prop('value'), 'lorem ipsum', '`$el.val(string)` should change the `value` property'); - assert.strictEqual(el.value, 'lorem ipsum', '`$el.val(string)` should change the `value` attribute'); - assert.ok(!$el.hasClass('placeholder'), '`$el.val(string)` should remove `placeholder` class'); + $el.val( 'lorem ipsum' ); + assert.strictEqual( $el.prop( 'value' ), 'lorem ipsum', '`$el.val(string)` should change the `value` property' ); + assert.strictEqual( el.value, 'lorem ipsum', '`$el.val(string)` should change the `value` attribute' ); + assert.ok( !$el.hasClass( 'placeholder' ), '`$el.val(string)` should remove `placeholder` class' ); // and clear it again - $el.val(''); - assert.strictEqual($el.prop('value'), '', '`$el.val("")` should change the `value` property'); - assert.strictEqual(el.value, placeholder, '`$el.val("")` should change the `value` attribute'); - assert.ok($el.hasClass('placeholder'), '`$el.val("")` should re-enable `placeholder` class'); + $el.val( '' ); + assert.strictEqual( $el.prop( 'value' ), '', '`$el.val("")` should change the `value` property' ); + assert.strictEqual( el.value, placeholder, '`$el.val("")` should change the `value` attribute' ); + assert.ok( $el.hasClass( 'placeholder' ), '`$el.val("")` should re-enable `placeholder` class' ); // make sure the placeholder property works as expected. - assert.strictEqual($el.prop('placeholder'), placeholder, '$el.prop(`placeholder`) should return the placeholder value'); - $el.placeholder('new placeholder'); - assert.strictEqual(el.getAttribute('placeholder'), 'new placeholder', '$el.placeholder() should set the placeholder value'); - assert.strictEqual(el.value, 'new placeholder', '$el.placeholder() should update the displayed placeholder value'); - $el.placeholder(placeholder); + assert.strictEqual( $el.prop( 'placeholder' ), placeholder, '$el.prop(`placeholder`) should return the placeholder value' ); + $el.placeholder( 'new placeholder' ); + assert.strictEqual( el.getAttribute( 'placeholder' ), 'new placeholder', '$el.placeholder() should set the placeholder value' ); + assert.strictEqual( el.value, 'new placeholder', '$el.placeholder() should update the displayed placeholder value' ); + $el.placeholder( placeholder ); }; - QUnit.test('emulates placeholder for ', 22, function (assert) { - $('
').html(html).appendTo($('#qunit-fixture')); - testElement($('#input-type-text'), assert); - }); + QUnit.test( 'emulates placeholder for ', 22, function ( assert ) { + $( '
' ).html( html ).appendTo( $( '#qunit-fixture' ) ); + testElement( $( '#input-type-text' ), assert ); + } ); - QUnit.test('emulates placeholder for ', 22, function (assert) { - $('
').html(html).appendTo($('#qunit-fixture')); - testElement($('#input-type-search'), assert); - }); + QUnit.test( 'emulates placeholder for ', 22, function ( assert ) { + $( '
' ).html( html ).appendTo( $( '#qunit-fixture' ) ); + testElement( $( '#input-type-search' ), assert ); + } ); - QUnit.test('emulates placeholder for ', 22, function (assert) { - $('
').html(html).appendTo($('#qunit-fixture')); - testElement($('#input-type-email'), assert); - }); + QUnit.test( 'emulates placeholder for ', 22, function ( assert ) { + $( '
' ).html( html ).appendTo( $( '#qunit-fixture' ) ); + testElement( $( '#input-type-email' ), assert ); + } ); - QUnit.test('emulates placeholder for ', 22, function (assert) { - $('
').html(html).appendTo($('#qunit-fixture')); - testElement($('#input-type-url'), assert); - }); + QUnit.test( 'emulates placeholder for ', 22, function ( assert ) { + $( '
' ).html( html ).appendTo( $( '#qunit-fixture' ) ); + testElement( $( '#input-type-url' ), assert ); + } ); - QUnit.test('emulates placeholder for ', 22, function (assert) { - $('
').html(html).appendTo($('#qunit-fixture')); - testElement($('#input-type-tel'), assert); - }); + QUnit.test( 'emulates placeholder for ', 22, function ( assert ) { + $( '
' ).html( html ).appendTo( $( '#qunit-fixture' ) ); + testElement( $( '#input-type-tel' ), assert ); + } ); - QUnit.test('emulates placeholder for ', 13, function (assert) { - $('
').html(html).appendTo($('#qunit-fixture')); + QUnit.test( 'emulates placeholder for ', 13, function ( assert ) { + $( '
' ).html( html ).appendTo( $( '#qunit-fixture' ) ); var selector = '#input-type-password', - $el = $(selector), - el = $el[0], - placeholder = el.getAttribute('placeholder'); + $el = $( selector ), + el = $el[ 0 ], + placeholder = el.getAttribute( 'placeholder' ); - assert.strictEqual($el.placeholder(), $el, 'should be chainable'); + assert.strictEqual( $el.placeholder(), $el, 'should be chainable' ); // Re-select the element, as it gets replaced by another one in some browsers - $el = $(selector); - el = $el[0]; + $el = $( selector ); + el = $el[ 0 ]; - assert.strictEqual(el.value, placeholder, 'should set `placeholder` text as `value`'); - assert.strictEqual($el.prop('value'), '', 'propHooks works properly'); - assert.strictEqual($el.val(), '', 'valHooks works properly'); - assert.ok($el.hasClass('placeholder'), 'should have `placeholder` class'); + assert.strictEqual( el.value, placeholder, 'should set `placeholder` text as `value`' ); + assert.strictEqual( $el.prop( 'value' ), '', 'propHooks works properly' ); + assert.strictEqual( $el.val(), '', 'valHooks works properly' ); + assert.ok( $el.hasClass( 'placeholder' ), 'should have `placeholder` class' ); // test on focus $el.focus(); // Re-select the element, as it gets replaced by another one in some browsers - $el = $(selector); - el = $el[0]; + $el = $( selector ); + el = $el[ 0 ]; - assert.strictEqual(el.value, '', '`value` should be the empty string on focus'); - assert.strictEqual($el.prop('value'), '', 'propHooks works properly'); - assert.strictEqual($el.val(), '', 'valHooks works properly'); - assert.ok(!$el.hasClass('placeholder'), 'should not have `placeholder` class on focus'); + assert.strictEqual( el.value, '', '`value` should be the empty string on focus' ); + assert.strictEqual( $el.prop( 'value' ), '', 'propHooks works properly' ); + assert.strictEqual( $el.val(), '', 'valHooks works properly' ); + assert.ok( !$el.hasClass( 'placeholder' ), 'should not have `placeholder` class on focus' ); // and unfocus (blur) again $el.blur(); // Re-select the element, as it gets replaced by another one in some browsers - $el = $(selector); - el = $el[0]; + $el = $( selector ); + el = $el[ 0 ]; - assert.strictEqual(el.value, placeholder, 'should set `placeholder` text as `value`'); - assert.strictEqual($el.prop('value'), '', 'propHooks works properly'); - assert.strictEqual($el.val(), '', 'valHooks works properly'); - assert.ok($el.hasClass('placeholder'), 'should have `placeholder` class'); + assert.strictEqual( el.value, placeholder, 'should set `placeholder` text as `value`' ); + assert.strictEqual( $el.prop( 'value' ), '', 'propHooks works properly' ); + assert.strictEqual( $el.val(), '', 'valHooks works properly' ); + assert.ok( $el.hasClass( 'placeholder' ), 'should have `placeholder` class' ); - }); + } ); - QUnit.test('emulates placeholder for ', 22, function (assert) { - $('
').html(html).appendTo($('#qunit-fixture')); - testElement($('#textarea'), assert); - }); + QUnit.test( 'emulates placeholder for ', 22, function ( assert ) { + $( '
' ).html( html ).appendTo( $( '#qunit-fixture' ) ); + testElement( $( '#textarea' ), assert ); + } ); -}(jQuery)); +}( jQuery ) );