mediawiki-extensions-Popups/tests/node-qunit/gateway/index.test.js
Thiemo Kreuz 170ab5422a Rename current gateway to pagePreviewGateway
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
2019-01-17 17:15:22 +00:00

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' );
} );