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 assert.throws( function () {
13 QUnit.test( 'Set up iframe upload', function ( assert ) {
15 var $iframe, $form, $input,
18 this.sandbox.stub( api, 'getEditToken', function () {
19 return $.Deferred().promise();
22 api.uploadWithIframe( $( '<input>' )[ 0 ], { filename: 'Testing API upload.jpg' } );
24 $iframe = $( 'iframe' );
25 $form = $( 'form.mw-api-upload-form' );
26 $input = $form.find( 'input[name=filename]' );
28 assert.ok( $form.length > 0 );
29 assert.ok( $input.length > 0 );
30 assert.ok( $iframe.length > 0 );
31 assert.strictEqual( $form.prop( 'target' ), $iframe.prop( 'id' ) );
32 assert.strictEqual( $input.val(), 'Testing API upload.jpg' );
35 }( mediaWiki, jQuery ) );