mediawiki-extensions-Popups/tests/node-qunit/gateway/index.test.js
joakin e6081106f1 Use EcmaScript modules instead of common.js modules
Why: Because they are the approved standard by TC39 and Ecma for
JavaScript modules.

Changes:
  * Wrap mw-node-qunit in run.js to register babel to transpile modules
    for node v6
  * Change all sources in src/ to use ES modules
    * Change constants.js to be able to run without
      jQuery.bracketedDevicePixelRatio given ES modules are hoisted to
      the top by spec so we can't patch globals before importing it
  * Change all tests in tests/node-qunit/ to use ES modules
  * Drop usage of mock-require given ES modules are easy to stub with
    sinon

Additional changes:
  * Rename tests/node-qunit/renderer.js to renderer.test.js to follow
    the convention of all the other files
  * Make npm run test:node run only .test.js test files so that it
    doesn't run the stubs.js or run.js file.

Bug: T171951
Change-Id: I17a0b76041d5e2fd18e2d54950d9d7c0db99a941
2017-07-31 23:05:44 +00:00

39 lines
1.3 KiB
JavaScript

import createGateway from '../../../src/gateway';
import * as RestModule from '../../../src/gateway/rest';
import * as MediawikiModule from '../../../src/gateway/mediawiki';
QUnit.module( 'gateway/index.js', {
beforeEach: function () {
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' );
createGateway( 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' );
createGateway( 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' );
createGateway( this.config );
assert.ok( this.createRESTBaseGateway.called, 'REST HTML gateway called' );
} );