mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-12-03 19:56:39 +00:00
170ab5422a
This is split from the current draft patch Ie0ccb03. This is part of a series of very small patches that prepare the code for new types of popups. We decided to not add code for other types of popups to the existing createGateway() function, but introduce new files and functions instead. Renaming, for example, the existing `gateway` variable name will make it much more obvious which of the future gateways does what. Bug: T213415 Change-Id: Ifcbc3ba53d0ab9ef67adf1f314defc76b4f89e89
42 lines
1.3 KiB
JavaScript
42 lines
1.3 KiB
JavaScript
import createPagePreviewGateway from '../../../src/gateway';
|
|
import * as RestModule from '../../../src/gateway/rest';
|
|
import * as MediawikiModule from '../../../src/gateway/mediawiki';
|
|
|
|
QUnit.module( 'gateway/index.js', {
|
|
beforeEach() {
|
|
mediaWiki.Api = function () {};
|
|
|
|
this.createMediaWikiApiGateway =
|
|
this.sandbox.stub( MediawikiModule, 'default' );
|
|
this.createRESTBaseGateway = this.sandbox.stub( RestModule, 'default' );
|
|
|
|
this.config = new Map(); /* global Map */
|
|
}
|
|
} );
|
|
|
|
QUnit.test( 'it uses mediawiki plain text gateway with wgPopupsGateway == "mwApiPlain"', function ( assert ) {
|
|
this.config.set( 'wgPopupsGateway', 'mwApiPlain' );
|
|
|
|
createPagePreviewGateway( this.config );
|
|
|
|
assert.ok( this.createMediaWikiApiGateway.called,
|
|
'MW plain text gateway called' );
|
|
} );
|
|
|
|
QUnit.test( 'it uses rest plain text gateway with wgPopupsGateway == "restbasePlain"', function ( assert ) {
|
|
this.config.set( 'wgPopupsGateway', 'restbasePlain' );
|
|
|
|
createPagePreviewGateway( this.config );
|
|
|
|
assert.ok( this.createRESTBaseGateway.called,
|
|
'REST plain text gateway called' );
|
|
} );
|
|
|
|
QUnit.test( 'it uses rest HTML gateway with wgPopupsGateway == "restbaseHTML"', function ( assert ) {
|
|
this.config.set( 'wgPopupsGateway', 'restbaseHTML' );
|
|
|
|
createPagePreviewGateway( this.config );
|
|
|
|
assert.ok( this.createRESTBaseGateway.called, 'REST HTML gateway called' );
|
|
} );
|