2017-06-15 11:35:19 +00:00
|
|
|
var mock = require( 'mock-require' ),
|
|
|
|
createGateway;
|
|
|
|
|
|
|
|
QUnit.module( 'gateway/index.js', {
|
|
|
|
beforeEach: function () {
|
|
|
|
jQuery.bracketedDevicePixelRatio = function () { return 1; };
|
|
|
|
mediaWiki.Api = function () {};
|
|
|
|
|
2017-06-15 17:58:36 +00:00
|
|
|
this.createMediaWikiApiGateway = this.sandbox.stub();
|
|
|
|
mock( '../../../src/gateway/mediawiki', this.createMediaWikiApiGateway );
|
|
|
|
this.createRESTBaseGateway = this.sandbox.stub();
|
|
|
|
mock( '../../../src/gateway/rest', this.createRESTBaseGateway );
|
2017-06-15 11:35:19 +00:00
|
|
|
|
|
|
|
createGateway = mock.reRequire( '../../../src/gateway' );
|
|
|
|
|
|
|
|
this.config = new Map(); /* global Map */
|
|
|
|
},
|
|
|
|
afterEach: function () {
|
|
|
|
jQuery.bracketedDevicePixelRatio = undefined;
|
2017-06-15 17:58:36 +00:00
|
|
|
mock.stop( '../../../src/gateway/mediawiki' );
|
|
|
|
mock.stop( '../../../src/gateway/rest' );
|
2017-06-15 11:35:19 +00:00
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
|
|
|
QUnit.test( 'it uses mediawiki plain text gateway with wgPopupsGateway == "mwApiPlain"', function ( assert ) {
|
|
|
|
this.config.set( 'wgPopupsGateway', 'mwApiPlain' );
|
|
|
|
|
|
|
|
createGateway( this.config );
|
|
|
|
|
2017-06-15 17:58:36 +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 );
|
|
|
|
|
2017-06-15 17:58:36 +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
|
|
|
} );
|