resources: Strip '$' and 'mw' from file closures
[lhc/web/wiklou.git] / tests / qunit / suites / resources / mediawiki.api / mediawiki.api.upload.test.js
1 ( function () {
2 QUnit.module( 'mediawiki.api.upload', QUnit.newMwEnvironment( {} ) );
3
4 QUnit.test( 'Basic functionality', function ( assert ) {
5 var api = new mw.Api();
6 assert.ok( api.upload );
7 assert.throws( function () {
8 api.upload();
9 } );
10 } );
11
12 QUnit.test( 'Set up iframe upload', function ( assert ) {
13 var $iframe, $form, $input,
14 api = new mw.Api();
15
16 this.sandbox.stub( api, 'getEditToken', function () {
17 return $.Deferred().promise();
18 } );
19
20 api.uploadWithIframe( $( '<input>' )[ 0 ], { filename: 'Testing API upload.jpg' } );
21
22 $iframe = $( 'iframe:last-child' );
23 $form = $( 'form.mw-api-upload-form' );
24 $input = $form.find( 'input[name=filename]' );
25
26 assert.ok( $form.length > 0, 'form' );
27 assert.ok( $input.length > 0, 'input' );
28 assert.ok( $iframe.length > 0, 'frame' );
29 assert.strictEqual( $form.prop( 'target' ), $iframe.prop( 'id' ), 'form.target and frame.id ' );
30 assert.strictEqual( $input.val(), 'Testing API upload.jpg', 'input value' );
31 } );
32
33 }() );