9
9
< script type ="text/javascript ">
10
10
11
11
QUnit . config . reorder = false ;
12
+ QUnit . config . testTimeout = 2000 ;
13
+ QUnit . config . autostart = false ;
14
+
15
+ FileHash . init ( {
16
+ files : [ 'files/01.min.js' , 'files/02.min.js' ] ,
17
+ onready : function ( ) {
18
+ QUnit . start ( ) ;
19
+ }
20
+ } ) ;
21
+
12
22
13
23
o . Env . swf_url = "../../js/flash/Moxie.swf" ;
14
24
o . Env . xap_url = "../../js/silverlight/Moxie.xap" ;
15
25
16
- module ( "Runtime" , {
17
- setup : function ( ) {
18
- } ,
19
26
27
+ module ( "Methods" , {
20
28
teardown : function ( ) {
29
+ $ ( '#qunit-fixture' ) . plupload ( 'destroy' ) ;
21
30
}
22
31
} ) ;
23
32
33
+ test ( "getUploader()" , function ( assert ) {
34
+ stop ( ) ;
35
+ $ ( '#qunit-fixture' ) . plupload ( {
36
+ runtimes : 'test' ,
37
+ url : '../upload.php' ,
38
+
39
+ ready : function ( e , o ) {
40
+ start ( ) ;
41
+ assert . ok ( $ ( this ) . plupload ( 'getUploader' ) instanceof plupload . Uploader ,
42
+ 'Retrieved a reference to an internal plupload.Uploader object.' ) ;
43
+ } ,
44
+
45
+ error : function ( ) {
46
+ start ( ) ;
47
+ assert . ok ( false , "Plupload didn't initialise." ) ;
48
+ }
49
+ } ) ;
50
+ } ) ;
51
+
52
+
53
+ test ( "refresh()" , function ( assert ) {
54
+ stop ( ) ;
55
+ $ ( '#qunit-fixture' ) . plupload ( {
56
+ runtimes : 'test' ,
57
+ url : '../upload.php' ,
58
+
59
+ ready : function ( e , o ) {
60
+ o . up . bind ( 'refresh' , function ( ) {
61
+ start ( ) ;
62
+ assert . ok ( true ,
63
+ 'Refresh has been triggered.' ) ;
64
+ } ) ;
65
+
66
+ $ ( this ) . plupload ( 'refresh' ) ;
67
+ } ,
68
+
69
+ error : function ( ) {
70
+ start ( ) ;
71
+ assert . ok ( false , "Plupload didn't initialise." ) ;
72
+ }
73
+ } ) ;
74
+ } ) ;
75
+
76
+
77
+
78
+
79
+
80
+ module ( "Events" , {
81
+ teardown : function ( ) {
82
+ $ ( '#qunit-fixture' ) . plupload ( 'destroy' ) ;
83
+ }
84
+ } ) ;
85
+
86
+ test ( 'ready' , function ( assert ) {
87
+ expect ( 2 ) ;
88
+ stop ( ) ;
89
+ $ ( '#qunit-fixture' ) . plupload ( {
90
+ runtimes : 'test' ,
91
+ url : '../upload.php' ,
92
+
93
+ ready : function ( e , o ) {
94
+ start ( ) ;
95
+ assert . ok ( true , 'ready fired.' ) ;
96
+ assert . ok ( o . up instanceof plupload . Uploader ,
97
+ 'Second arguments up property is plupload.Uploader object.' ) ;
98
+ } ,
99
+
100
+ error : function ( ) {
101
+ start ( ) ;
102
+ assert . ok ( false , "Plupload didn't initialise." ) ;
103
+ }
104
+ } ) ;
105
+ } ) ;
106
+
107
+
108
+ test ( 'selected (uses - event:ready)' , function ( assert ) {
109
+ var files = FileHash . getRuntimeFiles ( ) ;
110
+
111
+ stop ( ) ;
112
+ $ ( '#qunit-fixture' ) . plupload ( {
113
+ runtimes : 'test' ,
114
+ url : '../upload.php' ,
115
+
116
+ ready : function ( e , o ) {
117
+ o . up . addFile ( files ) ;
118
+ } ,
119
+
120
+ selected : function ( e , o ) {
121
+ start ( ) ;
122
+ assert . ok ( true , 'selected fired.' ) ;
123
+ assert . ok ( o . files , "Event object contains files property." ) ;
124
+ assert . equal ( o . files . length , files . length ,
125
+ files . length + " files were selected (added to the queue)" ) ;
126
+ assert . ok ( o . files [ 0 ] instanceof plupload . File , "Selected file is an instance of plupload.File." ) ;
127
+ } ,
128
+
129
+ error : function ( ) {
130
+ start ( ) ;
131
+ assert . ok ( false , "Plupload didn't initialise." ) ;
132
+ }
133
+ } ) ;
134
+ } ) ;
135
+
136
+
137
+ test ( 'started, stopped, progress, uploaded, complete (uses - event:ready, prop:autostart)' , function ( assert ) {
138
+ var files = FileHash . getRuntimeFiles ( ) ;
139
+
140
+ var events = {
141
+ started : 0 ,
142
+ stopped : 0 ,
143
+ progress : 0 ,
144
+ uploaded : 0 ,
145
+ complete : 0
146
+ } ;
147
+
148
+ stop ( ) ;
149
+ $ ( '#qunit-fixture' ) . plupload ( {
150
+ runtimes : 'test' ,
151
+ url : '../upload.php' ,
152
+ autostart : true ,
153
+
154
+ ready : function ( e , o ) {
155
+ o . up . addFile ( files [ 0 ] ) ;
156
+ } ,
157
+
158
+ started : function ( e , o ) {
159
+ events [ e . type ] ++ ;
160
+ } ,
161
+
162
+ stopped : function ( e , o ) {
163
+ events [ e . type ] ++ ;
164
+ } ,
165
+
166
+ progress : function ( e , o ) {
167
+ events [ e . type ] ++ ;
168
+ } ,
169
+
170
+ uploaded : function ( e , o ) {
171
+ events [ e . type ] ++ ;
172
+
173
+ assert . ok ( o . file instanceof plupload . File , "uploaded: Event object contains file property." ) ;
174
+ assert . equal ( typeof ( o . result ) , 'object' , "uploaded: Event object contains result property." ) ;
175
+
176
+ assert . deepEqual ( [
177
+ ! ! o . result . response ,
178
+ o . result . status ,
179
+ ! ! o . result . responseHeaders
180
+ ] , [
181
+ true ,
182
+ 200 ,
183
+ true
184
+ ] , "uploaded: result property contains server response, status code and response headers." ) ;
185
+ } ,
186
+
187
+ complete : function ( e , o ) {
188
+ start ( ) ;
189
+ events [ e . type ] ++ ;
190
+
191
+ assert . equal ( events . started , 1 , "start fired 1 time." ) ;
192
+ assert . equal ( events . stopped , 1 , "stop fired 1 time." ) ;
193
+ assert . ok ( events . progress , "progress fired " + events . progress + " time(s)." ) ;
194
+ assert . equal ( events . uploaded , 1 , "uploaded fired 1 time." ) ;
195
+ assert . equal ( events . complete , 1 , "complete fired 1 time." ) ;
196
+ } ,
197
+
198
+ error : function ( ) {
199
+ start ( ) ;
200
+ assert . ok ( false , "Plupload didn't initialise." ) ;
201
+ }
202
+ } ) ;
203
+ } ) ;
204
+
205
+
24
206
</ script >
25
207
</ head >
26
208
< body >
27
- < h1 id ="qunit-header "> Plupload Test Suite</ h1 >
28
- < h2 id ="qunit-banner "> </ h2 >
29
- < h2 id ="qunit-userAgent "> </ h2 >
30
- < ol id ="qunit-tests ">
31
- </ ol >
32
- < div id ="qunit-fixture " style ="position: relative; top: 0 !important; left: 0 !important; width: 100%; height: 9px; "> </ div >
209
+ < div id ="qunit "> </ div >
210
+ < div id ="qunit-fixture " style ="position: relative; top: 0 !important; left: 0 !important; width: 100%; height: auto; "> </ div >
33
211
</ body >
34
212
</ html >
0 commit comments