Index: trunk/extensions/UploadWizard/test/jasmine/spec/mw.pubsub.spec.js |
— | — | @@ -26,27 +26,66 @@ |
27 | 27 | expect( result2 ).toBe( sub1data ); |
28 | 28 | } ); |
29 | 29 | |
30 | | - it( "should allow timeline subscription with publishing after subscription", function() { |
| 30 | + it( "should allow ready subscription with publishing after subscription", function() { |
31 | 31 | var sub2data = [ 'quux', 'pif' ]; |
32 | 32 | var result; |
33 | | - $.subscribeTimeline( 'sub2', function( arg ) { |
| 33 | + $.subscribeReady( 'sub2', function( arg ) { |
34 | 34 | result = arg; |
35 | 35 | } ); |
36 | | - $.publishTimeline( 'sub2', sub2data ); |
| 36 | + $.publishReady( 'sub2', sub2data ); |
37 | 37 | expect( result ).toBe( sub2data ); |
38 | 38 | } ); |
39 | 39 | |
40 | 40 | |
41 | | - it( "should allow timeline subscription with subscription after publishing", function() { |
| 41 | + it( "should allow ready subscription with subscription after publishing", function() { |
42 | 42 | var sub3data = [ 'paf', 'klortho' ]; |
43 | 43 | var result; |
44 | | - $.publishTimeline( 'sub3', sub3data ); |
45 | | - $.subscribeTimeline( 'sub3', function( arg ) { |
| 44 | + $.publishReady( 'sub3', sub3data ); |
| 45 | + $.subscribeReady( 'sub3', function( arg ) { |
46 | 46 | result = arg; |
47 | 47 | } ); |
48 | 48 | expect( result ).toBe( sub3data ); |
49 | 49 | } ); |
50 | 50 | |
| 51 | + it( "should not allow a ready event to happen twice", function() { |
| 52 | + var first = [ 'paf' ]; |
| 53 | + var second = [ 'glom' ]; |
| 54 | + var result; |
| 55 | + $.publishReady( 'sub4', first ); |
| 56 | + $.publishReady( 'sub4', second ); |
| 57 | + $.subscribeReady( 'sub4', function( arg ) { |
| 58 | + result = arg; |
| 59 | + } ); |
| 60 | + expect( result ).toBe( first ); |
| 61 | + } ); |
| 62 | + |
| 63 | + it( "should purge subscriptions", function() { |
| 64 | + var data = [ 'paf' ]; |
| 65 | + var result1, result2; |
| 66 | + $.subscribeReady( 'sub5', function( arg ) { |
| 67 | + result1 = arg; |
| 68 | + } ); |
| 69 | + $.purgeSubscriptions(); |
| 70 | + $.subscribeReady( 'sub5', function( arg ) { |
| 71 | + result2 = arg; |
| 72 | + } ); |
| 73 | + $.publishReady( 'sub5', data ); |
| 74 | + expect( result1 ).not.toBeDefined(); |
| 75 | + expect( result2 ).toBe( data ); |
| 76 | + } ); |
| 77 | + |
| 78 | + it( "should purge ready events", function() { |
| 79 | + var data1 = [ 'paf' ]; |
| 80 | + var data2 = [ 'paf' ]; |
| 81 | + $.publishReady( 'sub6', data1 ); |
| 82 | + $.purgeReadyEvents(); |
| 83 | + $.publishReady( 'sub6', data2 ); |
| 84 | + $.subscribeReady( 'sub6', function( arg ) { |
| 85 | + result = arg; |
| 86 | + } ); |
| 87 | + expect( result ).toBe( data2 ); |
| 88 | + } ); |
| 89 | + |
51 | 90 | } ); |
52 | 91 | |
53 | 92 | } )( mediaWiki, jQuery ); |