Pablo Grass (WMDE) has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/385991 )
Change subject: ArbitraryWordInput: Add tests ...................................................................... ArbitraryWordInput: Add tests Add first tests for ArbitraryWordInput. Issue: T173563 Change-Id: I10737b380e2d6fe6c9c640cb76bc84e5c223725d --- M AdvancedSearch.hooks.php A tests/qunit/ui/ArbitraryWordInput.test.js 2 files changed, 36 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/AdvancedSearch refs/changes/91/385991/1 diff --git a/AdvancedSearch.hooks.php b/AdvancedSearch.hooks.php index eb2146d..016893c 100644 --- a/AdvancedSearch.hooks.php +++ b/AdvancedSearch.hooks.php @@ -83,6 +83,7 @@ public static function onResourceLoaderTestModules( array &$testModules, ResourceLoader $rl ) { $testModules['qunit']['ext.advancedSearch.tests'] = [ 'scripts' => [ + 'tests/qunit/ui/ArbitraryWordInput.test.js', 'tests/qunit/ui/NamespaceFilters.test.js', 'tests/qunit/ui/NamespacePresets.test.js', 'tests/qunit/ui/SearchPreview.test.js', @@ -91,6 +92,7 @@ 'tests/qunit/dm/FileTypeOptionProvider.test.js' ], 'dependencies' => [ + 'ext.advancedSearch.ui.ArbitraryWordInput', 'ext.advancedSearch.ui.NamespaceFilters', 'ext.advancedSearch.ui.NamespacePresets', 'ext.advancedSearch.ui.SearchPreview', diff --git a/tests/qunit/ui/ArbitraryWordInput.test.js b/tests/qunit/ui/ArbitraryWordInput.test.js new file mode 100644 index 0000000..96d9eb4 --- /dev/null +++ b/tests/qunit/ui/ArbitraryWordInput.test.js @@ -0,0 +1,34 @@ +( function ( mw ) { + var ArbitraryWordInput = mw.libs.advancedSearch.ui.ArbitraryWordInput, + Model = mw.libs.advancedSearch.dm.SearchModel; + + QUnit.module( 'ext.advancedSearch.ui.ArbitraryWordInput' ); + + QUnit.test( 'Placeholder text presented if no content', function ( assert ) { + assert.expect( 1 ); + + var input = new ArbitraryWordInput( new Model(), { placeholder: 'lorem ipsum' } ); + + assert.equal( input.getTextForPlaceholder(), 'lorem ipsum' ); + } ); + + QUnit.test( 'Placeholder text empty if content gets set', function ( assert ) { + assert.expect( 1 ); + + var input = new ArbitraryWordInput( new Model(), { placeholder: 'lorem ipsum' } ); + input.setValue( [ 'asinus' ] ); + + assert.equal( input.getTextForPlaceholder(), '' ); + } ); + + QUnit.test( 'Placeholder text empty if content set from the start', function ( assert ) { + assert.expect( 1 ); + + var model = new Model(); + model.storeOption( 'somekey', [ 'gaudiamus' ] ); + var input = new ArbitraryWordInput( model, { placeholder: 'lorem ipsum', optionId: 'somekey' } ); + + assert.equal( input.getTextForPlaceholder(), '' ); + } ); + +}( mediaWiki ) ); -- To view, visit https://gerrit.wikimedia.org/r/385991 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I10737b380e2d6fe6c9c640cb76bc84e5c223725d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/AdvancedSearch Gerrit-Branch: master Gerrit-Owner: Pablo Grass (WMDE) <pablo.gr...@wikimedia.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits