jenkins-bot has submitted this change and it was merged.
Change subject: RepoApi.js: Add searchEntities()
......................................................................
RepoApi.js: Add searchEntities()
Change-Id: Id4cbe324abe6d31602a421ee55972584158e23e4
---
M lib/resources/wikibase.RepoApi/wikibase.RepoApi.js
M lib/tests/qunit/wikibase.RepoApi/wikibase.RepoApi.tests.js
2 files changed, 56 insertions(+), 0 deletions(-)
Approvals:
Hoo man: Looks good to me, approved
jenkins-bot: Verified
diff --git a/lib/resources/wikibase.RepoApi/wikibase.RepoApi.js
b/lib/resources/wikibase.RepoApi/wikibase.RepoApi.js
index 9946867..cdc979b 100644
--- a/lib/resources/wikibase.RepoApi/wikibase.RepoApi.js
+++ b/lib/resources/wikibase.RepoApi/wikibase.RepoApi.js
@@ -137,6 +137,29 @@
},
/**
+ * Searches for entities containing the given text.
+ *
+ * @param {String} search search for this text
+ * @param {String} language search in this language
+ * @param {String} type search for this entity type
+ * @param {Number} limit maximum number of results to return
+ * @param {Number} offset offset where to continue the search
+ * @return {jQuery.Promise}
+ */
+ searchEntities: function( search, language, type, limit, offset ) {
+ var params = {
+ action: 'wbsearchentities',
+ search: search,
+ language: language,
+ type: type,
+ limit: limit || undefined,
+ 'continue': offset || undefined
+ };
+
+ return this.get( params );
+ },
+
+ /**
* Sets the label of an entity via the API.
*
* @param {String} id entity id
diff --git a/lib/tests/qunit/wikibase.RepoApi/wikibase.RepoApi.tests.js
b/lib/tests/qunit/wikibase.RepoApi/wikibase.RepoApi.tests.js
index f5b9c59..f1f4eb5 100644
--- a/lib/tests/qunit/wikibase.RepoApi/wikibase.RepoApi.tests.js
+++ b/lib/tests/qunit/wikibase.RepoApi/wikibase.RepoApi.tests.js
@@ -98,6 +98,39 @@
runTest();
} );
+ QUnit.test( 'Search for an entity', function( assert ) {
+ var data = {
+ labels: { de: {
+ language: 'de',
+ value: 'de-search-val'
+ } }
+ };
+
+ testrun.queue( qkey, function() { createItem( data ); } );
+
+ testrun.queue( qkey, function() {
+ api.searchEntities( data.labels.de.value,
data.labels.de.language, 'item', 2, 0 )
+ .done( function( response ) {
+
+ assert.ok(
+ response.search.length > 0,
+ 'Search results returned.'
+ );
+ assert.equal(
+ response.search[0].label,
+ data.labels.de.value,
+ 'Verified item label.'
+ );
+
+ testrun.dequeue( qkey );
+ } )
+ .fail( onFail );
+ } );
+
+ runTest();
+
+ });
+
QUnit.test( 'Edit an entity', function( assert ) {
testrun.queue( qkey, function() { createItem(); } );
--
To view, visit https://gerrit.wikimedia.org/r/71713
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Id4cbe324abe6d31602a421ee55972584158e23e4
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: LivingShadow <[email protected]>
Gerrit-Reviewer: Daniel Werner <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: LivingShadow <[email protected]>
Gerrit-Reviewer: Tobias Gritschacher <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits