2017-07-28 17:32:46 +00:00
|
|
|
import createGateway from '../../../src/gateway';
|
|
|
|
import * as RestModule from '../../../src/gateway/rest';
|
|
|
|
import * as MediawikiModule from '../../../src/gateway/mediawiki';
|
2017-06-15 11:35:19 +00:00
|
|
|
|
|
|
|
QUnit.module( 'gateway/index.js', {
|
2018-03-14 22:04:59 +00:00
|
|
|
beforeEach() {
|
2017-06-15 11:35:19 +00:00
|
|
|
mediaWiki.Api = function () {};
|
|
|
|
|
2018-01-18 18:48:16 +00:00
|
|
|
this.createMediaWikiApiGateway =
|
|
|
|
this.sandbox.stub( MediawikiModule, 'default' );
|
2017-07-28 17:32:46 +00:00
|
|
|
this.createRESTBaseGateway = this.sandbox.stub( RestModule, 'default' );
|
2017-06-15 11:35:19 +00:00
|
|
|
|
|
|
|
this.config = new Map(); /* global Map */
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
|
|
|
QUnit.test( 'it uses mediawiki plain text gateway with wgPopupsGateway == "mwApiPlain"', function ( assert ) {
|
|
|
|
this.config.set( 'wgPopupsGateway', 'mwApiPlain' );
|
|
|
|
|
|
|
|
createGateway( this.config );
|
|
|
|
|
2018-01-18 18:48:16 +00:00
|
|
|
assert.ok( this.createMediaWikiApiGateway.called,
|
|
|
|
'MW plain text gateway called' );
|
2017-06-15 11:35:19 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
QUnit.test( 'it uses rest plain text gateway with wgPopupsGateway == "restbasePlain"', function ( assert ) {
|
|
|
|
this.config.set( 'wgPopupsGateway', 'restbasePlain' );
|
|
|
|
|
|
|
|
createGateway( this.config );
|
|
|
|
|
2018-01-18 18:48:16 +00:00
|
|
|
assert.ok( this.createRESTBaseGateway.called,
|
|
|
|
'REST plain text gateway called' );
|
2017-06-15 11:35:19 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
QUnit.test( 'it uses rest HTML gateway with wgPopupsGateway == "restbaseHTML"', function ( assert ) {
|
|
|
|
this.config.set( 'wgPopupsGateway', 'restbaseHTML' );
|
|
|
|
|
|
|
|
createGateway( this.config );
|
|
|
|
|
2017-06-15 17:58:36 +00:00
|
|
|
assert.ok( this.createRESTBaseGateway.called, 'REST HTML gateway called' );
|
2017-06-15 11:35:19 +00:00
|
|
|
} );
|