summaryrefslogtreecommitdiff
path: root/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/qunit/suites/resources/mediawiki.api/mediawiki.api.test.js')
-rw-r--r--tests/qunit/suites/resources/mediawiki.api/mediawiki.api.test.js106
1 files changed, 54 insertions, 52 deletions
diff --git a/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.test.js b/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.test.js
index 79bd7306..9eda75ce 100644
--- a/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.test.js
+++ b/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.test.js
@@ -1,59 +1,61 @@
-QUnit.module( 'mediawiki.api', QUnit.newMwEnvironment() );
+( function ( mw ) {
+ QUnit.module( 'mediawiki.api', QUnit.newMwEnvironment() );
-QUnit.asyncTest( 'Basic functionality', function ( assert ) {
- var api, d1, d2, d3;
- QUnit.expect( 3 );
+ QUnit.asyncTest( 'Basic functionality', function ( assert ) {
+ var api, d1, d2, d3;
+ QUnit.expect( 3 );
- api = new mw.Api();
+ api = new mw.Api();
- d1 = api.get( {} )
- .done( function ( data ) {
- assert.deepEqual( data, [], 'If request succeeds without errors, resolve deferred' );
- });
+ d1 = api.get( {} )
+ .done( function ( data ) {
+ assert.deepEqual( data, [], 'If request succeeds without errors, resolve deferred' );
+ } );
- d2 = api.get({
+ d2 = api.get( {
action: 'doesntexist'
- })
- .fail( function ( errorCode, details ) {
- assert.equal( errorCode, 'unknown_action', 'API error (e.g. "unknown_action") should reject the deferred' );
- });
-
- d3 = api.post( {} )
- .done( function ( data ) {
- assert.deepEqual( data, [], 'Simple POST request' );
- });
-
- // After all are completed, continue the test suite.
- QUnit.whenPromisesComplete( d1, d2, d3 ).always( function () {
- QUnit.start();
- });
-});
-
-QUnit.asyncTest( 'Deprecated callback methods', function ( assert ) {
- var api, d1, d2, d3;
- QUnit.expect( 3 );
-
- api = new mw.Api();
-
- d1 = api.get( {}, function () {
- assert.ok( true, 'Function argument treated as success callback.' );
- });
-
- d2 = api.get( {}, {
- ok: function ( data ) {
- assert.ok( true, '"ok" property treated as success callback.' );
- }
- });
-
- d3 = api.get({
+ } )
+ .fail( function ( errorCode ) {
+ assert.equal( errorCode, 'unknown_action', 'API error (e.g. "unknown_action") should reject the deferred' );
+ } );
+
+ d3 = api.post( {} )
+ .done( function ( data ) {
+ assert.deepEqual( data, [], 'Simple POST request' );
+ } );
+
+ // After all are completed, continue the test suite.
+ QUnit.whenPromisesComplete( d1, d2, d3 ).always( function () {
+ QUnit.start();
+ } );
+ } );
+
+ QUnit.asyncTest( 'Deprecated callback methods', function ( assert ) {
+ var api, d1, d2, d3;
+ QUnit.expect( 3 );
+
+ api = new mw.Api();
+
+ d1 = api.get( {}, function () {
+ assert.ok( true, 'Function argument treated as success callback.' );
+ } );
+
+ d2 = api.get( {}, {
+ ok: function () {
+ assert.ok( true, '"ok" property treated as success callback.' );
+ }
+ } );
+
+ d3 = api.get( {
action: 'doesntexist'
}, {
- err: function ( data ) {
- assert.ok( true, '"err" property treated as error callback.' );
- }
- });
-
- QUnit.whenPromisesComplete( d1, d2, d3 ).always( function () {
- QUnit.start();
- });
-});
+ err: function () {
+ assert.ok( true, '"err" property treated as error callback.' );
+ }
+ } );
+
+ QUnit.whenPromisesComplete( d1, d2, d3 ).always( function () {
+ QUnit.start();
+ } );
+ } );
+}( mediaWiki ) );