2019-01-31 11:05:57 +00:00
|
|
|
import createPagePreviewGateway from '../../../src/gateway/page';
|
2017-07-28 17:32:46 +00:00
|
|
|
import * as RestModule from '../../../src/gateway/rest';
|
|
|
|
import * as MediawikiModule from '../../../src/gateway/mediawiki';
|
2017-06-15 11:35:19 +00:00
|
|
|
|
2019-01-31 14:38:41 +00:00
|
|
|
QUnit.module( 'gateway/page.js', {
|
2018-03-14 22:04:59 +00:00
|
|
|
beforeEach() {
|
2019-10-17 08:51:49 +00:00
|
|
|
mw.Api = function () {};
|
2017-06-15 11:35:19 +00:00
|
|
|
|
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
|
|
|
|
2019-09-17 11:47:25 +00:00
|
|
|
this.config = new Map();
|
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' );
|
|
|
|
|
2019-01-17 11:32:22 +00:00
|
|
|
createPagePreviewGateway( this.config );
|
2017-06-15 11:35:19 +00:00
|
|
|
|
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' );
|
|
|
|
|
2019-01-17 11:32:22 +00:00
|
|
|
createPagePreviewGateway( this.config );
|
2017-06-15 11:35:19 +00:00
|
|
|
|
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' );
|
|
|
|
|
2019-01-17 11:32:22 +00:00
|
|
|
createPagePreviewGateway( this.config );
|
2017-06-15 11:35:19 +00:00
|
|
|
|
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
|
|
|
} );
|