UNPKG

plupload

Version:

Plupload is a JavaScript API for dealing with file uploads it supports features like multiple file selection, file type filtering, request chunking, client side image scaling and it uses different runtimes to achieve this such as HTML 5, Silverlight and F

108 lines (80 loc) 2.52 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>HTML4: FileInput</title> <script src="../../../loader.js"></script> <script type="text/javascript"> QUnit.config.reorder = false; QUnit.config.testTimeout = 10000; module("HTML4: FileInput", { setup: function() { }, teardown: function() { } }); test("Test initialization", function(assert) { $('#qunit-fixture').append([ '<div id="container">', '<a id="browse_button" href="javascript:;">Browse...</a>', '</div>' ].join('')); var fi = new o.FileInput({ runtime_order: 'html4', browse_button: 'browse_button' }); fi.onready = function() { start(); var $container = $('#' + fi.shimid) , $form = $container.find('form') , $input = $form.children().filter('input[type="file"]') , formId , inputId ; assert.ok(true, "Ready event has fired."); assert.ok($form.length && $input.length, "HTML structure is correct"); // save ids for later () formId = $form.attr('id'); inputId = $input.attr('id'); fi.bind('change', function() { start(); var file = this.files[0]; assert.ok(true, "Change event has fired."); assert.equal(file.name, "test.jpg", "File selected."); // form ids should now be replaced to file specific assert.notEqual($form.attr('id'), formId, "Form id has changed."); assert.equal($form.attr('id'), file.uid + "_form", "Form id is now derived from file uid."); assert.notEqual($input.attr('id'), inputId, "Input id has changed."); assert.equal($input.attr('id'), file.uid, "Input id is now equal to file uid."); // form should be moved out of the view assert.equal($form.position().top, $container.height(), "Form is moved out of the view."); // new form should now fill the viewport assert.equal($container.find('form').length, 2, "New form has been appended to the container."); assert.equal($container.find('form:last').position().top, 0, "New form is in the view."); }); // fake change event ad file object stop(); $input[0].onchange.call({ value: "test.jpg" }); }; fi.bind("Error RuntimeError", function() { assert.ok(true, "Runtime not supported."); start(); }); stop(); fi.init(); }); </script> </head> <body> <h1 id="qunit-header">mOxie Test Suite</h1> <h2 id="qunit-banner"></h2> <h2 id="qunit-userAgent"></h2> <ol id="qunit-tests"> </ol> <div id="qunit-fixture" style="position: relative; top: 0 !important; left: 0 !important; width: 100%; height: 9px;"></div> </body> </html>