mediawiki-extensions-Popups/tests/node-qunit/gateway/page.test.js
WMDE-Fisch 0c0226c4ee Add and fix gateway/page module
Change-Id: Icd8e9e3a6f643ebba0c2bb9b4fcb84e1260d41ca
2019-02-01 11:14:00 +01:00

42 lines
1.3 KiB
JavaScript

import createPagePreviewGateway from '../../../src/gateway/page';
import * as RestModule from '../../../src/gateway/rest';
import * as MediawikiModule from '../../../src/gateway/mediawiki';
QUnit.module( 'gateway/page.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' );
} );