mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-11 20:13:28 +00:00
260 lines
8.4 KiB
HTML
260 lines
8.4 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title></title>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
<script src="../../../../../www/assets/vendors/jquery/jquery.js"></script>
|
|
<script src="../../../../../www/assets/vendors/jquery-ui/jquery-ui.js"></script>
|
|
<script src="../../../../../www/bower_components/qunit/qunit/qunit.js"></script>
|
|
<script src="../../../../../www/assets/vendors/blueimp-load-image/load-image.js"></script>
|
|
<script src="../components/upload/jquery.Upload.js"></script>
|
|
<link type="text/css" rel="stylesheet" href="../../../../../www/bower_components/qunit/qunit/qunit.css"/>
|
|
<script> $(document).ready(function(){
|
|
|
|
var getUploadManager = function(){
|
|
var UM = new p4.UploaderManager({
|
|
container : $(".container"),
|
|
uploadBox : $(".upload-box"),
|
|
settingsBox : $(".settings-box"),
|
|
downloadBox : $(".download-box")
|
|
});
|
|
|
|
return UM;
|
|
};
|
|
|
|
module("upload Manager");
|
|
|
|
test("bad parameters", function() {
|
|
raises(function() {
|
|
new p4.UploaderManager();
|
|
}, "must throw error to pass");
|
|
|
|
raises(function() {
|
|
new p4.UploaderManager({
|
|
container : $(".container"),
|
|
uploadBox : $(".upload-box"),
|
|
settingsBox : $(".settings-box"),
|
|
downloadBox : {}
|
|
});
|
|
}, "must throw error to pass");
|
|
|
|
raises(function() {
|
|
new p4.UploaderManager({
|
|
container : $(".container"),
|
|
uploadBox : $(".upload-box"),
|
|
settingsBox : $(".settings-box")
|
|
});
|
|
}, "must throw error to pass");
|
|
});
|
|
|
|
test("getContainer", function() {
|
|
var UM = getUploadManager();
|
|
deepEqual($(".container"), UM.getContainer());
|
|
});
|
|
|
|
test("getUploadBox", function() {
|
|
var UM = getUploadManager();
|
|
deepEqual($(".upload-box").find('ul:first'), UM.getUploadBox());
|
|
});
|
|
|
|
test("getSettingsBox", function() {
|
|
var UM = getUploadManager();
|
|
deepEqual($(".settings-box"), UM.getSettingsBox());
|
|
});
|
|
|
|
test("getDownloadBox", function() {
|
|
var UM = getUploadManager();
|
|
equal("thumbnails", UM.getDownloadBox().attr("class"));
|
|
});
|
|
|
|
test("clearUploadBox", function() {
|
|
var UM = getUploadManager();
|
|
UM.addData({test:'test'});
|
|
UM.clearUploadBox();
|
|
equal(0, UM.Queue.getLength());
|
|
equal(0, UM.getUploadIndex());
|
|
equal(0, UM.getUploadBox().find('*').length);
|
|
});
|
|
|
|
test("getDatas", function() {
|
|
var UM = getUploadManager();
|
|
|
|
UM.addData({test:'test'});
|
|
UM.addData({test:'toto'});
|
|
|
|
var datas = UM.getDatas();
|
|
var expected = {1:{test:"test", uploadIndex:1}, 2:{test:"toto", uploadIndex:2}};
|
|
deepEqual(datas, expected);
|
|
});
|
|
|
|
test("addData", function() {
|
|
var UM = getUploadManager();
|
|
|
|
UM.addData({test:'test'});
|
|
UM.addData({test:'toto'});
|
|
|
|
equal( UM.Queue.getLength(), 2);
|
|
equal(UM.getUploadIndex(), 2);
|
|
});
|
|
|
|
test("getData", function() {
|
|
var UM = getUploadManager();
|
|
|
|
UM.addData({test:'test'});
|
|
deepEqual(UM.getData(UM.getUploadIndex()), {test:'test', uploadIndex: 1});
|
|
UM.addData({test:'test'});
|
|
deepEqual(UM.getData(UM.getUploadIndex()), {test:'test', uploadIndex: 2});
|
|
});
|
|
|
|
test("addAttributeToData", function() {
|
|
var UM = getUploadManager();
|
|
|
|
UM.addData({test:'test'});
|
|
UM.addAttributeToData(UM.getUploadIndex(), 'test2', 'titi');
|
|
var data = UM.getData(UM.getUploadIndex());
|
|
|
|
ok("test2" in data);
|
|
equal(data.test2, 'titi');
|
|
});
|
|
|
|
test("getUploadIndex", function() {
|
|
var UM = getUploadManager();
|
|
UM.uploadIndex = 5;
|
|
equal(UM.getUploadIndex(), 5);
|
|
});
|
|
|
|
module("upload Manager Queue");
|
|
|
|
test("set", function() {
|
|
var UM = getUploadManager();
|
|
|
|
UM.Queue.set(32, {test:'test'});
|
|
equal(1, UM.Queue.getLength());
|
|
});
|
|
|
|
test("remove", function() {
|
|
var UM = getUploadManager();
|
|
|
|
UM.Queue.set(32, {test:'test'});
|
|
UM.Queue.remove(32);
|
|
|
|
equal(0, UM.Queue.getLength());
|
|
});
|
|
|
|
test("length", function() {
|
|
var UM = getUploadManager();
|
|
|
|
UM.Queue.set(32, {test:'test'});
|
|
UM.Queue.set(33, {test:'test'});
|
|
UM.Queue.set(34, {test:'test'});
|
|
UM.Queue.set(32, {test:'test'});
|
|
|
|
equal(3, UM.Queue.getLength());
|
|
});
|
|
|
|
test("all", function() {
|
|
var UM = getUploadManager();
|
|
|
|
UM.Queue.set(32, {test:'test'});
|
|
UM.Queue.set(33, {test:'test'});
|
|
UM.Queue.set(34, {test:'test'});
|
|
UM.Queue.set(32, {test:'test'});
|
|
|
|
var o = UM.Queue.all();
|
|
$.each(o, function(k, v){
|
|
equal(v, UM.Queue.get(k));
|
|
});
|
|
});
|
|
|
|
|
|
test("clear", function() {
|
|
var UM = getUploadManager();
|
|
|
|
UM.Queue.set(32, {test:'test'});
|
|
UM.Queue.set(33, {test:'test'});
|
|
UM.Queue.set(34, {test:'test'});
|
|
|
|
UM.Queue.clear();
|
|
equal(0, UM.Queue.getLength());
|
|
});
|
|
|
|
test("isEmpty", function() {
|
|
var UM = getUploadManager();
|
|
|
|
ok(UM.Queue.isEmpty());
|
|
|
|
UM.Queue.set(32, {test:'test'});
|
|
|
|
ok(!UM.Queue.isEmpty());
|
|
});
|
|
|
|
module("upload Manager Formater");
|
|
|
|
test("size", function() {
|
|
var UM = getUploadManager();
|
|
|
|
var convert = UM.Formater.size(125456589754);
|
|
equal('116.84 GB', convert);
|
|
convert = UM.Formater.size(12545);
|
|
equal('12.25 KB', convert);
|
|
convert = UM.Formater.size(565487585);
|
|
equal('539.29 MB', convert);
|
|
});
|
|
|
|
test("bitrate", function() {
|
|
var UM = getUploadManager();
|
|
|
|
var convert = UM.Formater.bitrate(125456589754);
|
|
equal('107.59 Mo/s', convert);
|
|
convert = UM.Formater.bitrate(12545);
|
|
equal('1.53 Ko/s', convert);
|
|
convert = UM.Formater.bitrate(565487585);
|
|
equal('67.41 Mo/s', convert);
|
|
});
|
|
|
|
module("upload Manager Preview");
|
|
|
|
test("setOptions & getOptions", function() {
|
|
var UM = getUploadManager();
|
|
|
|
var o = {
|
|
maxWidth: 600,
|
|
maxHeight: 480,
|
|
minWidth: 300,
|
|
minHeight: 200,
|
|
canvas : false
|
|
};
|
|
|
|
var defaultOptions = {
|
|
fileType: /^image\/(gif|jpeg|png|jpg)$/,
|
|
maxSize: 5242880
|
|
};
|
|
|
|
var expected = $.extend(defaultOptions, o);
|
|
|
|
UM.Preview.setOptions(o);
|
|
|
|
deepEqual(expected, UM.Preview.getOptions());
|
|
|
|
});
|
|
|
|
});
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<h1 id="qunit-header">QUnit example</h1>
|
|
<h2 id="qunit-banner"></h2>
|
|
<div id="qunit-testrunner-toolbar"></div>
|
|
<h2 id="qunit-userAgent"></h2>
|
|
<ol id="qunit-tests"></ol>
|
|
<div id="qunit-fixture">test markup, will be hidden</div>
|
|
|
|
<div class='container'>
|
|
<div class='upload-box'><p></p></div>
|
|
<div class='settings-box'></div>
|
|
<div class='download-box'></div>
|
|
</div>
|
|
|
|
</body>
|
|
</html>
|