Файловый менеджер - Редактировать - /var/www/html/qunit.zip
Ðазад
PK ! rm"� � * ext.enhancedUpload.paramsProcessor.test.jsnu �[��� ( function () { QUnit.module( 'ext.enhancedUpload.paramsProcessor.test', QUnit.newMwEnvironment() ); var tests = [ [ { prefix: 'ABC', filename: 'Test.txt', format: 'txt', ignorewarnings: true, comment: 'TestComment' }, { name: 'Test.txt' } ], [ { prefix: 'ABC:', filename: 'Test.txt', format: 'txt', ignorewarnings: true, comment: 'TestComment' }, { name: 'Test.txt' } ], [ { prefix: 'ABC:DEF', filename: 'Test.txt', format: 'txt', ignorewarnings: true, comment: 'TestComment' }, { name: 'Test.txt' } ], [ { prefix: 'ABC:DEF:', filename: 'Test.txt', format: 'txt', ignorewarnings: true, comment: 'TestComment' }, { name: 'Test.txt' } ] ]; var expectedParams = [ { filename: 'ABCTest.txt', format: 'txt', ignorewarnings: true, comment: 'TestComment', prefix: 'ABC' }, { filename: 'ABC_Test.txt', format: 'txt', ignorewarnings: true, comment: 'TestComment', prefix: 'ABC:' }, { filename: 'ABC_DEFTest.txt', format: 'txt', ignorewarnings: true, comment: 'TestComment', prefix: 'ABC:DEF' }, { filename: 'ABC_DEF_Test.txt', format: 'txt', ignorewarnings: true, comment: 'TestComment', prefix: 'ABC:DEF:' } ]; QUnit.test( 'ext.enhancedUpload.paramsProcessor.test', function ( assert ) { for ( var i = 0; i < 4; i++ ) { var processor = new enhancedUpload.ParamsProcessor(); var retrievedParams = processor.getParams( tests[ i ][ 0 ], tests[ i ][ 1 ], true ); assert.deepEqual( retrievedParams, expectedParams[ i ], 'params' ); } } ); }() ); PK ! ���=Z Z mw.fileApi.test.jsnu �[��� /* * This file is part of the MediaWiki extension MediaUploader. * * MediaUploader is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * MediaUploader is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with MediaUploader. If not, see <http://www.gnu.org/licenses/>. */ ( function () { QUnit.module( 'mw.fileApi', QUnit.newMwEnvironment() ); QUnit.test( 'isPreviewableFile', function ( assert ) { var testFile = {}; testFile.type = 'image/png'; testFile.size = 5 * 1024 * 1024; assert.strictEqual( mw.fileApi.isPreviewableFile( testFile ), true ); testFile.type = 'image/gif'; assert.strictEqual( mw.fileApi.isPreviewableFile( testFile ), true ); testFile.type = 'image/jpeg'; assert.strictEqual( mw.fileApi.isPreviewableFile( testFile ), true ); testFile.size = 11 * 1024 * 1024; assert.strictEqual( mw.fileApi.isPreviewableFile( testFile ), false ); testFile.size = 5 * 1024 * 1024; testFile.type = 'unplayable/type'; assert.strictEqual( mw.fileApi.isPreviewableFile( testFile ), false ); this.sandbox.stub( mw.fileApi, 'isPreviewableVideo' ).returns( true ); assert.strictEqual( mw.fileApi.isPreviewableFile( testFile ), true ); } ); QUnit.test( 'isPreviewableVideo', function ( assert ) { var result, testFile = {}, fakeVideo = { canPlayType: this.sandbox.stub().returns( 'yes' ) }; this.sandbox.stub( document, 'createElement' ).returns( fakeVideo ); result = mw.fileApi.isPreviewableVideo( testFile ); document.createElement.restore(); assert.strictEqual( result, true ); assert.strictEqual( fakeVideo.canPlayType.callCount, 1 ); fakeVideo.canPlayType = this.sandbox.stub().returns( 'no' ); this.sandbox.stub( document, 'createElement' ).returns( fakeVideo ); result = mw.fileApi.isPreviewableVideo( testFile ); document.createElement.restore(); assert.strictEqual( result, false ); assert.strictEqual( fakeVideo.canPlayType.callCount, 1 ); } ); }() ); PK ! ^q�I. I. uw.ConcurrentQueue.test.jsnu �[��� /* * This file is part of the MediaWiki extension MediaUploader. * * MediaUploader is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * MediaUploader is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with MediaUploader. If not, see <http://www.gnu.org/licenses/>. */ ( function ( uw ) { QUnit.module( 'uw.ConcurrentQueue', QUnit.newMwEnvironment() ); // This is a bogus action that will be executed for every item added to the // queue. We just need to make sure that the action doesn't complete // immediately, or the order some methods are called in could be slightly // different (e.g. when adding a new item after one has just completed will // trigger the next one to execute, which would terminate immediately, // instead of giving time for a second new thingy to be added) function queueAction() { var deferred = $.Deferred(); setTimeout( deferred.resolve, 10 ); return deferred.promise(); } // Asserts that the given stub functions were called in the given order. // SinonJS's assert.callOrder doesn't allow to check individual calls. function assertCalledInOrder() { var calls, i, currSpyCall, nextSpyCall; // Map stubs to specific calls calls = Array.prototype.map.call( arguments, function ( spy ) { if ( !spy.assertCallsInOrderLastCall ) { spy.assertCallsInOrderLastCall = 0; } return spy.getCall( spy.assertCallsInOrderLastCall++ ); } ); // Assert stuff for ( i = 0; i < calls.length - 1; i++ ) { currSpyCall = calls[ i ]; nextSpyCall = calls[ i + 1 ]; if ( currSpyCall ) { QUnit.assert.true( currSpyCall.callId < ( nextSpyCall ? nextSpyCall.callId : -1 ), 'Call ' + ( i + 1 ) + ' (callId ' + currSpyCall.callId + ') is in the right order' ); } else { QUnit.assert.true( false, 'Call ' + ( i + 1 ) + ' (never called) is in the right order' ); } } QUnit.assert.true( !!nextSpyCall, 'Call ' + calls.length + ' is in the right order' ); } QUnit.test( 'Basic behavior', function ( assert ) { var done, action, queue; done = assert.async(); action = sinon.spy( queueAction ); queue = new uw.ConcurrentQueue( { count: 3, action: action } ); queue.on( 'progress', function () { QUnit.assert.true( queue.running.length <= 3, 'No more than 3 items are executing' ); } ); queue.on( 'complete', function () { // All items executed sinon.assert.callCount( action, 5 ); // All items executed in the expected order sinon.assert.calledWith( action.getCall( 0 ), 'a' ); sinon.assert.calledWith( action.getCall( 1 ), 'b' ); sinon.assert.calledWith( action.getCall( 2 ), 'c' ); sinon.assert.calledWith( action.getCall( 3 ), 'd' ); sinon.assert.calledWith( action.getCall( 4 ), 'e' ); done(); } ); [ 'a', 'b', 'c', 'd', 'e' ].forEach( function ( v ) { queue.addItem( v ); } ); queue.startExecuting(); } ); QUnit.test( 'Event emitting', function ( assert ) { var done, changeHandler, progressHandler, completeHandler, queue; done = assert.async(); changeHandler = sinon.stub(); progressHandler = sinon.stub(); completeHandler = sinon.stub(); queue = new uw.ConcurrentQueue( { count: 3, action: queueAction } ); queue.connect( null, { change: changeHandler, progress: progressHandler, complete: completeHandler } ); queue.on( 'complete', function () { sinon.assert.callCount( changeHandler, 3 ); sinon.assert.callCount( progressHandler, 3 ); sinon.assert.callCount( completeHandler, 1 ); assertCalledInOrder( changeHandler, // Added 'a' changeHandler, // Added 'b' changeHandler, // Added 'c' progressHandler, // Finished 'a', 'b' or 'c' progressHandler, // Finished 'a', 'b' or 'c' progressHandler, // Finished 'a', 'b' or 'c' completeHandler ); done(); } ); queue.addItem( 'a' ); queue.addItem( 'b' ); queue.addItem( 'c' ); queue.startExecuting(); } ); QUnit.test( 'Restarting a completed queue', function ( assert ) { var done, queue; done = assert.async(); queue = new uw.ConcurrentQueue( { count: 3, action: queueAction } ); queue.addItem( 'a' ); queue.addItem( 'b' ); queue.addItem( 'c' ); queue.once( 'complete', function () { QUnit.assert.equal( queue.completed, true ); queue.addItem( 'd' ); queue.addItem( 'e' ); queue.once( 'complete', function () { QUnit.assert.equal( queue.completed, true ); done(); } ); queue.startExecuting(); } ); queue.startExecuting(); } ); QUnit.test( 'Empty queue completes', function ( assert ) { var done, queue; done = assert.async(); queue = new uw.ConcurrentQueue( { count: 3, action: queueAction } ); queue.on( 'complete', function () { QUnit.assert.equal( queue.completed, true ); done(); } ); queue.startExecuting(); } ); QUnit.test( 'Adding new items while queue running', function ( assert ) { var done, changeHandler, progressHandler, completeHandler, queue; done = assert.async(); changeHandler = sinon.stub(); progressHandler = sinon.stub(); completeHandler = sinon.stub(); queue = new uw.ConcurrentQueue( { count: 2, action: queueAction } ); queue.connect( null, { change: changeHandler, progress: progressHandler, complete: completeHandler } ); queue.on( 'complete', function () { sinon.assert.callCount( changeHandler, 6 ); sinon.assert.callCount( progressHandler, 6 ); sinon.assert.callCount( completeHandler, 1 ); assertCalledInOrder( changeHandler, // Added 'a' changeHandler, // Added 'b' changeHandler, // Added 'c' progressHandler, // Finished 'a' or 'b' changeHandler, // Added 'd' changeHandler, // Added 'e' progressHandler, // Finished 'a', 'b' or 'c' progressHandler, // Finished 'a', 'b', 'c' or 'd' progressHandler, // Finished 'a', 'b', 'c', 'd' or 'e' progressHandler, // Finished 'a', 'b', 'c', 'd' or 'e' changeHandler, // Added 'f' progressHandler, // Finished f' completeHandler ); done(); } ); queue.addItem( 'a' ); queue.addItem( 'b' ); queue.addItem( 'c' ); queue.once( 'progress', function () { queue.addItem( 'd' ); queue.addItem( 'e' ); } ); queue.on( 'progress', function () { if ( queue.done.length === 5 ) { queue.addItem( 'f' ); } } ); queue.startExecuting(); } ); QUnit.test( 'Deleting items while queue running', function ( assert ) { var done, changeHandler, progressHandler, completeHandler, queue; done = assert.async(); changeHandler = sinon.stub(); progressHandler = sinon.stub(); completeHandler = sinon.stub(); queue = new uw.ConcurrentQueue( { count: 2, action: queueAction } ); queue.connect( null, { change: changeHandler, progress: progressHandler, complete: completeHandler } ); queue.on( 'complete', function () { sinon.assert.callCount( changeHandler, 8 ); sinon.assert.callCount( progressHandler, 4 ); sinon.assert.callCount( completeHandler, 1 ); assertCalledInOrder( changeHandler, // Added 'a' changeHandler, // Added 'b' changeHandler, // Added 'c' changeHandler, // Added 'd' changeHandler, // Added 'e' changeHandler, // Added 'f' progressHandler, // Finished 'a' or 'b' changeHandler, // Removed first of the queued (not executing), which is 'd' progressHandler, // Finished 'a', 'b' or 'c' changeHandler, // Removed the last one queued (not executing), which is 'f' progressHandler, // Finished 'a', 'b', 'c' or 'e' progressHandler, // Finished 'a', 'b', 'c' or 'e' completeHandler ); done(); } ); queue.addItem( 'a' ); queue.addItem( 'b' ); queue.addItem( 'c' ); queue.addItem( 'd' ); queue.addItem( 'e' ); queue.addItem( 'f' ); queue.once( 'progress', function () { queue.removeItem( queue.queued[ 0 ] ); queue.once( 'progress', function () { queue.removeItem( queue.queued[ 0 ] ); } ); } ); queue.startExecuting(); } ); QUnit.test( 'Deleting currently running item', function ( assert ) { var done, action, changeHandler, progressHandler, completeHandler, queue; done = assert.async(); action = sinon.spy( queueAction ); changeHandler = sinon.stub(); progressHandler = sinon.stub(); completeHandler = sinon.stub(); queue = new uw.ConcurrentQueue( { count: 2, action: action } ); queue.connect( null, { change: changeHandler, progress: progressHandler, complete: completeHandler } ); queue.on( 'complete', function () { // Every item in the queue was executed... sinon.assert.callCount( action, 4 ); sinon.assert.callCount( changeHandler, 5 ); // ...but the one we removed wasn't registered as finished sinon.assert.callCount( progressHandler, 3 ); sinon.assert.callCount( completeHandler, 1 ); assertCalledInOrder( changeHandler, // Added 'a' changeHandler, // Added 'b' changeHandler, // Added 'c' changeHandler, // Added 'd' action, // Started 'a' action, // Started 'b' progressHandler, // Finished 'a' or 'b' changeHandler, // Removed first of the executing, which is 'a' or 'b' action, // Started 'c' action, // Started 'd' - note how two threads are running still progressHandler, // Finished 'c' or 'd' progressHandler, // Finished 'c' or 'd' completeHandler ); done(); } ); queue.addItem( 'a' ); queue.addItem( 'b' ); queue.addItem( 'c' ); queue.addItem( 'd' ); queue.once( 'progress', function () { queue.removeItem( queue.running[ 0 ] ); } ); queue.startExecuting(); } ); QUnit.test( 'Adding a new item when almost done', function ( assert ) { var done, action, changeHandler, progressHandler, completeHandler, queue, onProgress; done = assert.async(); // This test seems extra flaky and was occasionally failing, double the delays action = sinon.spy( queueAction ); changeHandler = sinon.stub(); progressHandler = sinon.stub(); completeHandler = sinon.stub(); queue = new uw.ConcurrentQueue( { count: 2, action: action } ); queue.connect( null, { change: changeHandler, progress: progressHandler, complete: completeHandler } ); queue.on( 'complete', function () { sinon.assert.callCount( action, 5 ); sinon.assert.callCount( changeHandler, 5 ); sinon.assert.callCount( progressHandler, 5 ); sinon.assert.callCount( completeHandler, 1 ); assertCalledInOrder( changeHandler, // Added 'a' changeHandler, // Added 'b' changeHandler, // Added 'c' changeHandler, // Added 'd' action, // Started 'a' action, // Started 'b' progressHandler, // Finished 'a' or 'b' action, // Started 'c' progressHandler, // Finished 'a', 'b' or 'c' action, // Started 'd' progressHandler, // Finished 'a', 'b', 'c' or 'd' changeHandler, // Added 'e' action, // Started 'e' -- this starts a new thread progressHandler, // Finished 'a', 'b', 'c', 'd' or 'e' progressHandler, // Finished 'a', 'b', 'c', 'd' or 'e' completeHandler ); done(); } ); queue.addItem( 'a' ); queue.addItem( 'b' ); queue.addItem( 'c' ); queue.addItem( 'd' ); onProgress = function () { if ( queue.done.length === 3 ) { queue.addItem( 'e' ); queue.off( 'progress', onProgress ); } }; queue.on( 'progress', onProgress ); queue.startExecuting(); } ); }( mw.uploadWizard ) ); PK ! Q�T>� � uw.TitleDetailsWidget.test.jsnu �[��� ( function ( uw ) { 'use strict'; var fileNs, makeTitleInFileNSCases; fileNs = mw.config.get( 'wgFormattedNamespaces' )[ 6 ]; makeTitleInFileNSCases = [ { filename: 'foo.png', prefixedText: fileNs + ':Foo.png', desc: 'filename without namespace starting with a lower case letter' }, { filename: 'foo_bar-baz.jpg', prefixedText: fileNs + ':Foo bar-baz.jpg', desc: 'filename without namespace with space in it' }, { filename: 'MediaWiki:foo_bar.jpg', prefixedText: null, desc: 'filename starting with MediaWiki: (colons are disallowed)' }, { filename: 'File:foo_bar.jpg', prefixedText: fileNs + ':Foo bar.jpg', desc: 'filename starting with File:' }, { filename: 'file:foo_bar.jpg', prefixedText: fileNs + ':Foo bar.jpg', desc: 'filename starting with file:' }, { filename: 'Foo part 1/2.jpg', prefixedText: null, desc: 'filename with characters disallowed in file names' }, { filename: 'Foo #1.jpg', prefixedText: null, desc: 'filename including a # (disallowed in file names)' } ]; QUnit.module( 'uw.TitleDetailsWidget', QUnit.newMwEnvironment() ); QUnit.test( '.static.makeTitleInFileNS()', function ( assert ) { var makeTitleInFileNS = uw.TitleDetailsWidget.static.makeTitleInFileNS; makeTitleInFileNSCases.forEach( function ( test ) { var title = makeTitleInFileNS( test.filename ); assert.strictEqual( title ? title.getPrefixedText() : title, test.prefixedText, test.desc ); } ); } ); }( mw.uploadWizard ) ); PK ! �n�� � # mw.UploadWizardLicenseInput.test.jsnu �[��� QUnit.module( 'ext.uploadWizardLicenseInput', QUnit.newMwEnvironment( { beforeEach: function () { mw.UploadWizard.config = { licenses: { 'cc-by-sa-3.0': { msg: 'mediauploader-license-cc-by-sa-3.0', icons: [ 'cc-by', 'cc-sa' ], url: '//creativecommons.org/licenses/by-sa/3.0/', languageCodePrefix: 'deed.' } } }; } } ) ); QUnit.test( 'Smoke test', function ( assert ) { var config = { type: 'radio', licenses: [] }, $fixture = $( '<div>' ), uwLicenseInput; uwLicenseInput = new mw.UploadWizardLicenseInput( config ); $fixture.append( uwLicenseInput.$element ); assert.true( !!uwLicenseInput, 'LicenseInput object created !' ); } ); QUnit.test( 'createInputs()', function ( assert ) { var config = { type: 'radio', licenses: [ 'cc-by-sa-3.0' ] }, $fixture = $( '<div>' ), uwLicenseInput, $input, $label; uwLicenseInput = new mw.UploadWizardLicenseInput( config ); $fixture.append( uwLicenseInput.$element ); // Check radio button is there $input = $fixture.find( '.oo-ui-radioInputWidget .oo-ui-inputWidget-input[value="cc-by-sa-3.0"]' ); assert.strictEqual( $input.length, 1, 'Radio button created.' ); // Check label is there $label = $input.closest( '.oo-ui-radioOptionWidget' ).find( '.oo-ui-labelElement-label' ); assert.strictEqual( $label.length, 1, 'Label created.' ); } ); QUnit.test( 'createGroupedInputs()', function ( assert ) { var config = { type: 'checkbox', licenseGroups: [ { head: 'mediauploader-license-cc-head', subhead: 'mediauploader-license-cc-subhead', licenses: [ 'cc-by-sa-3.0' ] } ] }, $fixture = $( '<div>' ), uwLicenseInput; uwLicenseInput = new mw.UploadWizardLicenseInput( config ); $fixture.append( uwLicenseInput.$element ); // Check license group is there assert.strictEqual( $fixture.find( '.mediauploader-deed-license-group' ).length, 1, 'License group created.' ); // Check subheader is there assert.strictEqual( $fixture.find( '.mediauploader-deed-license-group-subhead' ).length, 1, 'License subheader created.' ); // Check license is there assert.strictEqual( $fixture.find( '.mediauploader-deed-license-group .oo-ui-fieldsetLayout-group' ).length, 1, 'License created.' ); } ); PK ! S \� � mw.UploadWizardUpload.test.jsnu �[��� /* * This file is part of the MediaWiki extension MediaUploader. * * MediaUploader is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * MediaUploader is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with MediaUploader. If not, see <http://www.gnu.org/licenses/>. */ ( function () { QUnit.module( 'mw.UploadWizardUpload', QUnit.newMwEnvironment() ); function createUpload( filename ) { var upload, oldconf = mw.UploadWizard.config; mw.UploadWizard.config = {}; upload = new mw.UploadWizardUpload( { api: { defaults: { ajax: {} } } }, { name: filename } ); mw.UploadWizard.config = oldconf; return upload; } QUnit.test( 'constructor sanity test', function ( assert ) { var upload = createUpload(); assert.true( !!upload ); } ); QUnit.test( 'getBasename', function ( assert ) { var upload; upload = createUpload( 'path/to/filename.png' ); assert.strictEqual( upload.getBasename(), 'filename.png', 'Path is stripped' ); upload = createUpload( 'filename.png' ); assert.strictEqual( upload.getBasename(), 'filename.png', 'Only filename is left alone' ); upload = createUpload( '///////////' ); assert.strictEqual( upload.getBasename(), '', 'Nonsensical path is just removed' ); } ); }() ); PK ! ���? .eslintrc.jsonnu �[��� { "root": true, "extends": [ "wikimedia/server", "wikimedia/jquery", "wikimedia/mediawiki", "wikimedia/qunit" ], "globals": { "sinon": "readonly" }, "env": { "browser": true }, "rules": { "compat/compat": "off", "qunit/no-loose-assertions": "warn" } } PK ! g�x % controller/uw.controller.Step.test.jsnu �[��� /* * This file is part of the MediaWiki extension MediaUploader. * * MediaUploader is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * MediaUploader is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with MediaUploader. If not, see <http://www.gnu.org/licenses/>. */ ( function ( uw ) { QUnit.module( 'uw.controller.Step', QUnit.newMwEnvironment() ); QUnit.test( 'Constructor sanity test', function ( assert ) { var step = new uw.controller.Step( { on: function () {} }, new mw.Api(), {} ); assert.true( !!step ); assert.true( !!step.ui ); } ); }( mw.uploadWizard ) ); PK ! )��E� � '