forked from moxiecode/plupload
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.html
More file actions
152 lines (119 loc) · 4.49 KB
/
api.html
File metadata and controls
152 lines (119 loc) · 4.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Core API tests</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="stylesheet" href="qunit/qunit.css" type="text/css" media="screen">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="qunit/jquery.simulate.js"></script>
<script type="text/javascript" src="qunit/qunit.js"></script>
<script type="text/javascript" src="qunit/runner.js"></script>
<script type="text/javascript" src="js/utils.js"></script>
<script type="text/javascript" src="../js/plupload.full.min.js"></script>
<script>
module("Core API");
test('cleanName', function() {
expect(1);
equals(plupload.cleanName('a\300\340\307\347\310-\313\350\314\317\354\321\361\322\362\331\371 b'), 'aAaCcE-EeIIiNnOoUu_b');
});
test('extend', function() {
expect(1);
deepEqual(plupload.extend({a:1}, {b:2}), {a:1, b:2});
});
test('parseSize', function() {
expect(7);
equals(plupload.parseSize(1024), 1024, 1024);
equals(plupload.parseSize('1024k'), 1048576, '"1024k"');
equals(plupload.parseSize('1024kb'), 1048576, '"1024kb"');
equals(plupload.parseSize('1024Kb'), 1048576, '"1024Kb"');
equals(plupload.parseSize('2mb'), 2097152, '"2mb"');
equals(plupload.parseSize('4gb'), 4294967296, '"4gb"');
equals(plupload.parseSize('4b'), 4, 4);
});
test('formatSize', function() {
var undef;
//expect(6);
equals(plupload.formatSize(undef), 'N/A', 'undefined');
equals(plupload.formatSize('abcdefg'), 'N/A', '"abcdefg"');
equals(plupload.formatSize('4294967296'), '4 GB', '"4294967296"');
});
test('addEvent, removeEvent, removeAllEvents', function() {
expect(17);
$('<div id="test-button">Test Button</div>')
.appendTo('#qunit-fixture');
var undef,
testButton = $('#test-button'),
uniqid1 = plupload.guid(),
uniqid2 = plupload.guid(),
events = {},
handler = function (event) {
events[event.type] = true;
},
addEvent = function(type) {
plupload.addEvent(testButton[0], type, handler, arguments[1]);
testButton.simulate(type, { cancelable: true, bubbles: true });
ok(events[type], type + ' handler attached' + (arguments[1] === undef ? '':' (key:' + arguments[1] +')'));
delete events[type];
},
removeEvent = function(type) {
var third = '';
switch (typeof(arguments[1])) {
case 'function':
third = ', callback';
break;
case 'string':
third = ', key';
break
}
plupload.removeEvent(testButton[0], type, arguments[1]);
testButton.simulate( type, { cancelable: true, bubbles: true });
ok(!events[type], type + ' handler removed (plupload.removeEvent(obj, name'+third+'))');
},
removeAllEvents = function(type) {
var second = typeof(arguments[1]) == 'string' ? ', key' : '';
plupload.removeAllEvents(testButton[0], arguments[1]);
testButton.simulate( type, { cancelable: true, bubbles: true });
ok(!events[type], type + ' handler removed (plupload.removeAllEvents(obj'+second+'))');
},
testEvent = function(type) {
testButton.simulate( type, { cancelable: true, bubbles: true });
ok(events[type], type + ' handler still attached');
delete events[type];
};
addEvent('dblclick');
addEvent('mouseup', uniqid1);
// test event remove with key and handler undefined
removeEvent('dblclick');
// test if locked event handler still there
testEvent('mouseup');
// test event remove with handler defined
addEvent('dblclick');
removeEvent('dblclick', handler);
testEvent('mouseup');
// test all events remove with key and handler undefined
addEvent('dblclick');
removeAllEvents('dblclick');
testEvent('mouseup');
// test event remove with key defined
addEvent('dblclick');
removeEvent('mouseup', uniqid1);
testEvent('dblclick');
// test all events remove with key defined
addEvent('mouseup', uniqid1);
removeAllEvents('mouseup', uniqid1);
testEvent('dblclick');
// remove all events finally
removeAllEvents('dblclick');
});
</script>
</head>
<body>
<h1 id="qunit-header">Core API tests</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"></div>
<div id="content"></div>
</body>
</html>