http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89916
Revision: 89916
Author: neilk
Date: 2011-06-12 05:20:28 +0000 (Sun, 12 Jun 2011)
Log Message:
-----------
tests for pubsub and units.bytes
Modified Paths:
--------------
trunk/extensions/UploadWizard/test/jasmine/SpecRunner.html
trunk/extensions/UploadWizard/test/jasmine/spec/mw.units.spec.js
Added Paths:
-----------
trunk/extensions/UploadWizard/test/jasmine/spec/mw.pubsub.spec.js
Modified: trunk/extensions/UploadWizard/test/jasmine/SpecRunner.html
===================================================================
--- trunk/extensions/UploadWizard/test/jasmine/SpecRunner.html 2011-06-12
05:17:38 UTC (rev 89915)
+++ trunk/extensions/UploadWizard/test/jasmine/SpecRunner.html 2011-06-12
05:20:28 UTC (rev 89916)
@@ -20,6 +20,7 @@
<script type="text/javascript" src="../../resources/mw.Api.edit.js"></script>
<script type="text/javascript" src="../../resources/mw.Title.js"></script>
<script type="text/javascript" src="../../resources/mw.units.js"></script>
+ <script type="text/javascript"
src="../../resources/jquery/jquery.pubsub.js"></script>
<script type="text/javascript"
src="spec/mediawiki.language.parser.spec.data.js"></script>
@@ -33,6 +34,7 @@
<script type="text/javascript" src="spec/mw.Title.spec.js"></script>
<script type="text/javascript" src="spec/mw.units.spec.js"></script>
+ <script type="text/javascript" src="spec/mw.pubsub.spec.js"></script>
</head>
<body>
Added: trunk/extensions/UploadWizard/test/jasmine/spec/mw.pubsub.spec.js
===================================================================
--- trunk/extensions/UploadWizard/test/jasmine/spec/mw.pubsub.spec.js
(rev 0)
+++ trunk/extensions/UploadWizard/test/jasmine/spec/mw.pubsub.spec.js
2011-06-12 05:20:28 UTC (rev 89916)
@@ -0,0 +1,52 @@
+( function( mw, $ ) {
+ describe( "mw.pubsub", function() {
+
+ it( "should allow subscription", function() {
+ var sub1data = [ 'foo', 'bar' ];
+ var result;
+ $.subscribe( 'sub1', function( arg ) {
+ result = arg;
+ } );
+ $.publish( 'sub1', sub1data );
+ expect( result ).toBe( sub1data );
+ } );
+
+ it( "should allow multiple subscription", function() {
+ var sub1data = [ 'foo', 'bar' ];
+ var result;
+ var result2;
+ $.subscribe( 'sub1', function( arg ) {
+ result = arg;
+ } );
+ $.subscribe( 'sub1', function( arg ) {
+ result2 = arg;
+ } );
+ $.publish( 'sub1', sub1data );
+ expect( result ).toBe( sub1data );
+ expect( result2 ).toBe( sub1data );
+ } );
+
+ it( "should allow timeline subscription with publishing after
subscription", function() {
+ var sub2data = [ 'quux', 'pif' ];
+ var result;
+ $.subscribeTimeline( 'sub2', function( arg ) {
+ result = arg;
+ } );
+ $.publishTimeline( 'sub2', sub2data );
+ expect( result ).toBe( sub2data );
+ } );
+
+
+ it( "should allow timeline subscription with subscription after
publishing", function() {
+ var sub3data = [ 'paf', 'klortho' ];
+ var result;
+ $.publishTimeline( 'sub3', sub3data );
+ $.subscribeTimeline( 'sub3', function( arg ) {
+ result = arg;
+ } );
+ expect( result ).toBe( sub3data );
+ } );
+
+ } );
+
+} )( mediaWiki, jQuery );
Property changes on:
trunk/extensions/UploadWizard/test/jasmine/spec/mw.pubsub.spec.js
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: trunk/extensions/UploadWizard/test/jasmine/spec/mw.units.spec.js
===================================================================
--- trunk/extensions/UploadWizard/test/jasmine/spec/mw.units.spec.js
2011-06-12 05:17:38 UTC (rev 89915)
+++ trunk/extensions/UploadWizard/test/jasmine/spec/mw.units.spec.js
2011-06-12 05:20:28 UTC (rev 89916)
@@ -16,28 +16,44 @@
expect( mw.units.bytes( 0 ) ).toEqual( '0 bytes' );
} );
- it( "should say 7 bytes", function() {
+ it( "should say bytes", function() {
expect( mw.units.bytes( 7 ) ).toEqual( '7 bytes' );
} );
- it( "should say 900 bytes", function() {
+ it( "should say bytes (900)", function() {
expect( mw.units.bytes( 900 ) ).toEqual( '900 bytes' );
} );
- it( "should say 1 K", function() {
+ it( "should say 1023 = 1023 bytes", function() {
+ expect( mw.units.bytes( 1023 ) ).toEqual( '1023 bytes'
);
+ } );
+
+ it( "should say 1024 = 1K", function() {
expect( mw.units.bytes( 1024 ) ).toEqual( '1 K' );
} );
- it( "should say 2.00 MB", function() {
+ it( "should say MB", function() {
expect( mw.units.bytes( 2 * 1024 * 1024 ) ).toEqual(
'2.00 MB' );
} );
- it( "should say 3.14 GB", function() {
+ it( "should say GB", function() {
expect( mw.units.bytes( 3.141592 * 1024 * 1024 * 1024 )
).toEqual( '3.14 GB' );
} );
+ it( "should say TB", function() {
+ expect( mw.units.bytes( 3.141592 * 1024 * 1024 * 1024 *
1024 ) ).toEqual( '3.14 TB' );
+ } );
+ it( "should say TB even when much larger", function() {
+ expect( mw.units.bytes( 3.141592 * 1024 * 1024 * 1024 *
1024 * 1024 ) ).toEqual( '3216.99 TB' );
+ } );
+
+ it( "should round up", function() {
+ expect( mw.units.bytes( 1.42857 * 1024 * 1024 * 1024 )
).toEqual( '1.43 GB' );
+ } );
+
+
} );
} )( mediaWiki );
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs