9d0fdf54b00eb72a2f9c916bf8d6ee82077c9abd
2 QUnit
.module( 'mediawiki.ForeignApi', QUnit
.newMwEnvironment( {
4 this.server
= this.sandbox
.useFakeServer();
5 this.server
.respondImmediately
= true;
6 this.clock
= this.sandbox
.useFakeTimers();
8 teardown: function () {
9 // https://github.com/jquery/jquery/issues/2453
14 QUnit
.test( 'origin is included in GET requests', function ( assert
) {
16 var api
= new mw
.ForeignApi( '//localhost:4242/w/api.php' );
18 this.server
.respond( function ( request
) {
19 assert
.ok( request
.url
.match( /origin=/ ), 'origin is included in GET requests' );
20 request
.respond( 200, { 'Content-Type': 'application/json' }, '[]' );
26 QUnit
.test( 'origin is included in POST requests', function ( assert
) {
28 var api
= new mw
.ForeignApi( '//localhost:4242/w/api.php' );
30 this.server
.respond( function ( request
) {
31 assert
.ok( request
.requestBody
.match( /origin=/ ), 'origin is included in POST request body' );
32 assert
.ok( request
.url
.match( /origin=/ ), 'origin is included in POST request URL, too' );
33 request
.respond( 200, { 'Content-Type': 'application/json' }, '[]' );