All files / mobile.startup/references ReferencesGateway.js

100% Statements 5/5
100% Branches 0/0
100% Functions 1/1
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45                    3x                                 1x             1x             1x   1x  
/**
 * Abstract base class
 * Gateway for retrieving references
 *
 * @class ReferencesGateway
 * @abstract
 *
 * @param {mw.Api} api
 */
function ReferencesGateway( api ) {
	this.api = api;
}
 
/**
 * Return the matched reference via API or DOM query
 *
 * @memberof ReferencesGateway
 * @instance
 * @param {string} id CSS selector
 * @param {Page} page to find reference for
 * @param {PageHTMLParser} pageHTMLParser
 * @return {jQuery.Promise} resolves with an Object representing reference
 *  with a `text` property
 *  The promise should be rejected with ReferenceGateway.ERROR_NOT_EXIST:
 *  if the reference is not found.
 *  If for some reason locating the reference fails return ReferenceGateway.ERROR_OTHER.
 */
ReferencesGateway.prototype.getReference = null;
 
/**
 * @memberof ReferencesGateway
 * @property ERROR_NOT_EXIST error code to be returned by getReference
 *  when a reference does not exist.
 */
ReferencesGateway.ERROR_NOT_EXIST = 'NOT_EXIST_ERROR';
/**
 * @memberof ReferencesGateway
 * @property ERROR_OTHER error code to be returned by getReference
 *  under any other circumstance not covered
 *  by ERROR_NOT_EXIST. It should be used if it is unclear whether a reference exists or not.
 */
ReferencesGateway.ERROR_OTHER = 'OTHER_ERROR';
 
module.exports = ReferencesGateway;