2 QUnit.module( 'mediawiki.api.upload', QUnit.newMwEnvironment( {} ) );
4 QUnit.test( 'Basic functionality', 2, function ( assert ) {
5 var api = new mw.Api();
6 assert.ok( api.upload );
7 assert.throws( function () {
12 QUnit.test( 'Set up iframe upload', 5, function ( assert ) {
13 var $iframe, $form, $input,
16 this.sandbox.stub( api, 'getEditToken', function () {
17 return $.Deferred().promise();
20 api.uploadWithIframe( $( '<input>' )[ 0 ], { filename: 'Testing API upload.jpg' } );
22 $iframe = $( 'iframe' );
23 $form = $( 'form.mw-api-upload-form' );
24 $input = $form.find( 'input[name=filename]' );
26 assert.ok( $form.length > 0 );
27 assert.ok( $input.length > 0 );
28 assert.ok( $iframe.length > 0 );
29 assert.strictEqual( $form.prop( 'target' ), $iframe.prop( 'id' ) );
30 assert.strictEqual( $input.val(), 'Testing API upload.jpg' );
33 }( mediaWiki, jQuery ) );