2 QUnit
.module( 'mediawiki.api.upload', QUnit
.newMwEnvironment( {} ) );
4 QUnit
.test( 'Basic functionality', function ( assert
) {
6 var api
= new mw
.Api();
7 assert
.ok( api
.upload
);
8 // The below will return a rejected deferred, but that's OK.
9 assert
.ok( api
.upload() );
12 QUnit
.test( 'Set up iframe upload', function ( assert
) {
14 var $iframe
, $form
, $input
,
17 this.sandbox
.stub( api
, 'getEditToken', function () {
18 return $.Deferred().promise();
21 api
.uploadWithIframe( $( '<input>' )[0], { filename
: 'Testing API upload.jpg' } );
23 $iframe
= $( 'iframe' );
24 $form
= $( 'form.mw-api-upload-form' );
25 $input
= $form
.find( 'input[name=filename]' );
27 assert
.ok( $form
.length
> 0 );
28 assert
.ok( $input
.length
> 0 );
29 assert
.ok( $iframe
.length
> 0 );
30 assert
.strictEqual( $form
.prop( 'target' ), $iframe
.prop( 'id' ) );
31 assert
.strictEqual( $input
.val(), 'Testing API upload.jpg' );
34 }( mediaWiki
, jQuery
) );