Index: trunk/extensions/UploadWizard/test/jasmine/SpecRunner.html |
— | — | @@ -20,6 +20,7 @@ |
21 | 21 | <script type="text/javascript" src="../../resources/mw.Api.edit.js"></script> |
22 | 22 | <script type="text/javascript" src="../../resources/mw.Title.js"></script> |
23 | 23 | <script type="text/javascript" src="../../resources/mw.units.js"></script> |
| 24 | + <script type="text/javascript" src="../../resources/jquery/jquery.pubsub.js"></script> |
24 | 25 | |
25 | 26 | <script type="text/javascript" src="spec/mediawiki.language.parser.spec.data.js"></script> |
26 | 27 | |
— | — | @@ -33,6 +34,7 @@ |
34 | 35 | |
35 | 36 | <script type="text/javascript" src="spec/mw.Title.spec.js"></script> |
36 | 37 | <script type="text/javascript" src="spec/mw.units.spec.js"></script> |
| 38 | + <script type="text/javascript" src="spec/mw.pubsub.spec.js"></script> |
37 | 39 | |
38 | 40 | </head> |
39 | 41 | <body> |
Index: trunk/extensions/UploadWizard/test/jasmine/spec/mw.pubsub.spec.js |
— | — | @@ -0,0 +1,52 @@ |
| 2 | +( function( mw, $ ) { |
| 3 | + describe( "mw.pubsub", function() { |
| 4 | + |
| 5 | + it( "should allow subscription", function() { |
| 6 | + var sub1data = [ 'foo', 'bar' ]; |
| 7 | + var result; |
| 8 | + $.subscribe( 'sub1', function( arg ) { |
| 9 | + result = arg; |
| 10 | + } ); |
| 11 | + $.publish( 'sub1', sub1data ); |
| 12 | + expect( result ).toBe( sub1data ); |
| 13 | + } ); |
| 14 | + |
| 15 | + it( "should allow multiple subscription", function() { |
| 16 | + var sub1data = [ 'foo', 'bar' ]; |
| 17 | + var result; |
| 18 | + var result2; |
| 19 | + $.subscribe( 'sub1', function( arg ) { |
| 20 | + result = arg; |
| 21 | + } ); |
| 22 | + $.subscribe( 'sub1', function( arg ) { |
| 23 | + result2 = arg; |
| 24 | + } ); |
| 25 | + $.publish( 'sub1', sub1data ); |
| 26 | + expect( result ).toBe( sub1data ); |
| 27 | + expect( result2 ).toBe( sub1data ); |
| 28 | + } ); |
| 29 | + |
| 30 | + it( "should allow timeline subscription with publishing after subscription", function() { |
| 31 | + var sub2data = [ 'quux', 'pif' ]; |
| 32 | + var result; |
| 33 | + $.subscribeTimeline( 'sub2', function( arg ) { |
| 34 | + result = arg; |
| 35 | + } ); |
| 36 | + $.publishTimeline( 'sub2', sub2data ); |
| 37 | + expect( result ).toBe( sub2data ); |
| 38 | + } ); |
| 39 | + |
| 40 | + |
| 41 | + it( "should allow timeline subscription with subscription after publishing", function() { |
| 42 | + var sub3data = [ 'paf', 'klortho' ]; |
| 43 | + var result; |
| 44 | + $.publishTimeline( 'sub3', sub3data ); |
| 45 | + $.subscribeTimeline( 'sub3', function( arg ) { |
| 46 | + result = arg; |
| 47 | + } ); |
| 48 | + expect( result ).toBe( sub3data ); |
| 49 | + } ); |
| 50 | + |
| 51 | + } ); |
| 52 | + |
| 53 | +} )( mediaWiki, jQuery ); |
Property changes on: trunk/extensions/UploadWizard/test/jasmine/spec/mw.pubsub.spec.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 54 | + native |
Index: trunk/extensions/UploadWizard/test/jasmine/spec/mw.units.spec.js |
— | — | @@ -16,28 +16,44 @@ |
17 | 17 | expect( mw.units.bytes( 0 ) ).toEqual( '0 bytes' ); |
18 | 18 | } ); |
19 | 19 | |
20 | | - it( "should say 7 bytes", function() { |
| 20 | + it( "should say bytes", function() { |
21 | 21 | expect( mw.units.bytes( 7 ) ).toEqual( '7 bytes' ); |
22 | 22 | } ); |
23 | 23 | |
24 | | - it( "should say 900 bytes", function() { |
| 24 | + it( "should say bytes (900)", function() { |
25 | 25 | expect( mw.units.bytes( 900 ) ).toEqual( '900 bytes' ); |
26 | 26 | } ); |
27 | 27 | |
28 | | - it( "should say 1 K", function() { |
| 28 | + it( "should say 1023 = 1023 bytes", function() { |
| 29 | + expect( mw.units.bytes( 1023 ) ).toEqual( '1023 bytes' ); |
| 30 | + } ); |
| 31 | + |
| 32 | + it( "should say 1024 = 1K", function() { |
29 | 33 | expect( mw.units.bytes( 1024 ) ).toEqual( '1 K' ); |
30 | 34 | } ); |
31 | 35 | |
32 | | - it( "should say 2.00 MB", function() { |
| 36 | + it( "should say MB", function() { |
33 | 37 | expect( mw.units.bytes( 2 * 1024 * 1024 ) ).toEqual( '2.00 MB' ); |
34 | 38 | } ); |
35 | 39 | |
36 | | - it( "should say 3.14 GB", function() { |
| 40 | + it( "should say GB", function() { |
37 | 41 | expect( mw.units.bytes( 3.141592 * 1024 * 1024 * 1024 ) ).toEqual( '3.14 GB' ); |
38 | 42 | } ); |
39 | 43 | |
| 44 | + it( "should say TB", function() { |
| 45 | + expect( mw.units.bytes( 3.141592 * 1024 * 1024 * 1024 * 1024 ) ).toEqual( '3.14 TB' ); |
| 46 | + } ); |
40 | 47 | |
| 48 | + it( "should say TB even when much larger", function() { |
| 49 | + expect( mw.units.bytes( 3.141592 * 1024 * 1024 * 1024 * 1024 * 1024 ) ).toEqual( '3216.99 TB' ); |
| 50 | + } ); |
41 | 51 | |
| 52 | + |
| 53 | + it( "should round up", function() { |
| 54 | + expect( mw.units.bytes( 1.42857 * 1024 * 1024 * 1024 ) ).toEqual( '1.43 GB' ); |
| 55 | + } ); |
| 56 | + |
| 57 | + |
42 | 58 | } ); |
43 | 59 | |
44 | 60 | } )( mediaWiki ); |