2 QUnit.module( 'mediawiki.ForeignApi', QUnit.newMwEnvironment( {
4 this.server = this.sandbox.useFakeServer();
5 this.server.respondImmediately = true;
9 QUnit.test( 'origin is included in GET requests', 1, function ( assert ) {
10 var api = new mw.ForeignApi( '//localhost:4242/w/api.php' );
12 this.server.respond( function ( request ) {
13 assert.ok( request.url.match( /origin=/ ), 'origin is included in GET requests' );
14 request.respond( 200, { 'Content-Type': 'application/json' }, '[]' );
20 QUnit.test( 'origin is included in POST requests', 2, function ( assert ) {
21 var api = new mw.ForeignApi( '//localhost:4242/w/api.php' );
23 this.server.respond( function ( request ) {
24 assert.ok( request.requestBody.match( /origin=/ ), 'origin is included in POST request body' );
25 assert.ok( request.url.match( /origin=/ ), 'origin is included in POST request URL, too' );
26 request.respond( 200, { 'Content-Type': 'application/json' }, '[]' );
29 return api.post( {} );