Make sure that SQLite uses no prefix
[lhc/web/wiklou.git] / tests / qunit / suites / resources / mediawiki.api / mediawiki.api.test.js
1 QUnit.module( 'mediawiki.api', QUnit.newMwEnvironment() );
2
3 QUnit.asyncTest( 'Basic functionality', function ( assert ) {
4 var api, d1, d2, d3;
5 QUnit.expect( 3 );
6
7 api = new mw.Api();
8
9 d1 = api.get( {} )
10 .done( function ( data ) {
11 assert.deepEqual( data, [], 'If request succeeds without errors, resolve deferred' );
12 });
13
14 d2 = api.get({
15 action: 'doesntexist'
16 })
17 .fail( function ( errorCode, details ) {
18 assert.equal( errorCode, 'unknown_action', 'API error (e.g. "unknown_action") should reject the deferred' );
19 });
20
21 d3 = api.post( {} )
22 .done( function ( data ) {
23 assert.deepEqual( data, [], 'Simple POST request' );
24 });
25
26 // After all are completed, continue the test suite.
27 QUnit.whenPromisesComplete( d1, d2, d3 ).always( function () {
28 QUnit.start();
29 });
30 });
31
32 QUnit.asyncTest( 'Deprecated callback methods', function ( assert ) {
33 var api, d1, d2, d3;
34 QUnit.expect( 3 );
35
36 api = new mw.Api();
37
38 d1 = api.get( {}, function () {
39 assert.ok( true, 'Function argument treated as success callback.' );
40 });
41
42 d2 = api.get( {}, {
43 ok: function ( data ) {
44 assert.ok( true, '"ok" property treated as success callback.' );
45 }
46 });
47
48 d3 = api.get({
49 action: 'doesntexist'
50 }, {
51 err: function ( data ) {
52 assert.ok( true, '"err" property treated as error callback.' );
53 }
54 });
55
56 QUnit.whenPromisesComplete( d1, d2, d3 ).always( function () {
57 QUnit.start();
58 });
59 });