Api: remove obsolete getQueryField function

Obsolete since Ia4388fe4d5e1d6112a992e826453cd5799a6a4b4.

Bug: T77349
Change-Id: I13efa32786a2ba65edbaedde214057e9efe98145
This commit is contained in:
Simon Legner 2024-05-28 11:26:38 +02:00
parent 2fdb205fc6
commit 0399ffff40
2 changed files with 0 additions and 50 deletions

View file

@ -117,24 +117,6 @@ class Api {
return errorMessage;
}
/**
* Returns a promise with the specified field from the API result.
* This is intended to be used as a .then() callback for action=query APIs.
*
* @param {string} field
* @param {Object} data
* @return {jQuery.Promise} when successful, the first argument will be the field data,
* when unsuccessful, it will be an error message. The second argument is always
* the full API response.
*/
getQueryField( field, data ) {
if ( data && data.query && data.query[ field ] ) {
return $.Deferred().resolve( data.query[ field ], data );
} else {
return $.Deferred().reject( this.getErrorMessage( data ), data );
}
}
/**
* Returns a promise with the specified page from the API result.
* This is intended to be used as a .then() callback for action=query&prop=(...) APIs.

View file

@ -143,38 +143,6 @@ const { Api } = require( 'mmv' );
assert.strictEqual( apiProvider.getErrorMessage( {} ), 'unknown error', 'missing error message is handled' );
} );
QUnit.test( 'getQueryField', function ( assert ) {
const api = { get: function () {} };
const apiProvider = new Api( api );
const done = assert.async( 3 );
const data = {
query: {
imageusage: [
{
pageid: 736,
ns: 0,
title: 'Albert Einstein'
}
]
}
};
apiProvider.getQueryField( 'imageusage', data ).then( function ( field ) {
assert.strictEqual( field, data.query.imageusage, 'specified field is found' );
done();
} );
apiProvider.getQueryField( 'imageusage', {} ).fail( function () {
assert.true( true, 'promise rejected when data is missing' );
done();
} );
apiProvider.getQueryField( 'imageusage', { data: { query: {} } } ).fail( function () {
assert.true( true, 'promise rejected when field is missing' );
done();
} );
} );
QUnit.test( 'getQueryPage', function ( assert ) {
const api = { get: function () {} };
const apiProvider = new Api( api );