diff --git a/RevisionSlider.hooks.php b/RevisionSlider.hooks.php index a40076d1..fb66023b 100755 --- a/RevisionSlider.hooks.php +++ b/RevisionSlider.hooks.php @@ -86,6 +86,9 @@ class RevisionSliderHooks { 'ext.RevisionSlider.Slider', 'ext.RevisionSlider.SliderView', 'ext.RevisionSlider.RevisionList', + 'jquery.ui.draggable', + 'jquery.ui.tooltip', + 'jquery.tipsy', ], 'localBasePath' => __DIR__, ]; diff --git a/modules/ext.RevisionSlider.RevisionList.js b/modules/ext.RevisionSlider.RevisionList.js index 9a052a94..65ed6ed5 100644 --- a/modules/ext.RevisionSlider.RevisionList.js +++ b/modules/ext.RevisionSlider.RevisionList.js @@ -1,5 +1,6 @@ ( function ( mw, $ ) { var RevisionList = function ( revs ) { + this.revisions = []; this.initialize( revs ); this.view = new mw.libs.revisionSlider.RevisionListView( this ); }; diff --git a/tests/RevisionSlider.Slider.test.js b/tests/RevisionSlider.Slider.test.js index 9e6122b0..303376fc 100644 --- a/tests/RevisionSlider.Slider.test.js +++ b/tests/RevisionSlider.Slider.test.js @@ -1,58 +1,54 @@ ( function ( mw ) { var Slider = mw.libs.revisionSlider.Slider, - // RevisionList = mw.libs.revisionSlider.RevisionList, - Revision = mw.libs.revisionSlider.Revision; - - // function makeNRevisions( n ) { - // var revs = [], - // i; - // - // for ( i = 0; i < n; i++ ) { - // revs.push( new Revision( {} ) ); - // } - // - // return new RevisionList( revs ); - // } + RevisionList = mw.libs.revisionSlider.RevisionList, + Revision = mw.libs.revisionSlider.Revision, + makeNRevisions = function ( n ) { + var revs = [], + i; + for ( i = 0; i < n; i++ ) { + revs.push( new Revision( { user: 'Fooo' } ) ); + } + return new RevisionList( revs ); + }; QUnit.module( 'ext.RevisionSlider.Slider' ); QUnit.test( 'has revisions', function ( assert ) { - var revs = [ new Revision( {} ), new Revision( {} ) ], + var revs = new RevisionList( [ new Revision( {} ), new Revision( {} ) ] ), slider = new Slider( revs ); assert.equal( slider.getRevisions(), revs ); } ); - // TODO FIX ME! - // QUnit.test( 'Given no revisions, first visible revision index is 0', function ( assert ) { - // var slider = new Slider( [] ); - // - // assert.equal( slider.getFirstVisibleRevisionIndex(), 0 ); - // } ); - // - // QUnit.test( 'Given 200 revisions sliding once increases firstVisibleRevisionIndex by the number of revisions per window', function ( assert ) { - // var slider = new Slider( makeNRevisions( 200 ) ); - // slider.setRevisionsPerWindow( 50 ); - // slider.slide( 1 ); - // - // assert.equal( slider.getFirstVisibleRevisionIndex(), 50 ); - // } ); - // - // QUnit.test( 'firstVisibleRevisionIndex cannot be higher than revisions.length - revisionsPerWindow', function ( assert ) { - // var slider = new Slider( makeNRevisions( 75 ) ); - // slider.setRevisionsPerWindow( 50 ); - // slider.slide( 1 ); - // - // assert.equal( slider.getFirstVisibleRevisionIndex(), 24 ); - // } ); - // - // QUnit.test( 'firstVisibleRevisionIndex cannot be lower than 0', function ( assert ) { - // var slider = new Slider( makeNRevisions( 50 ) ); - // slider.firstVisibleRevisionIndex = 10; - // slider.setRevisionsPerWindow( 20 ); - // slider.slide( -1 ); - // - // assert.equal( slider.getFirstVisibleRevisionIndex(), 0 ); - // } ); + QUnit.test( 'Given no revisions, first visible revision index is 0', function ( assert ) { + var slider = new Slider( makeNRevisions( 0 ) ); + + assert.equal( slider.getFirstVisibleRevisionIndex(), 0 ); + } ); + + QUnit.test( 'Given 200 revisions sliding once increases firstVisibleRevisionIndex by the number of revisions per window', function ( assert ) { + var slider = new Slider( makeNRevisions( 200 ) ); + slider.setRevisionsPerWindow( 50 ); + slider.slide( 1 ); + + assert.equal( slider.getFirstVisibleRevisionIndex(), 50 ); + } ); + + QUnit.test( 'firstVisibleRevisionIndex cannot be higher than revisions.length - revisionsPerWindow', function ( assert ) { + var slider = new Slider( makeNRevisions( 75 ) ); + slider.setRevisionsPerWindow( 50 ); + slider.slide( 1 ); + + assert.equal( slider.getFirstVisibleRevisionIndex(), 24 ); + } ); + + QUnit.test( 'firstVisibleRevisionIndex cannot be lower than 0', function ( assert ) { + var slider = new Slider( makeNRevisions( 50 ) ); + slider.firstVisibleRevisionIndex = 10; + slider.setRevisionsPerWindow( 20 ); + slider.slide( -1 ); + + assert.equal( slider.getFirstVisibleRevisionIndex(), 0 ); + } ); } )( mediaWiki ); diff --git a/tests/RevisionSlider.SliderView.test.js b/tests/RevisionSlider.SliderView.test.js index db6fb4f4..86db9747 100644 --- a/tests/RevisionSlider.SliderView.test.js +++ b/tests/RevisionSlider.SliderView.test.js @@ -1,16 +1,21 @@ -( function () { - // var SliderView = mw.libs.revisionSlider.SliderView, - // Slider = mw.libs.revisionSlider.Slider; +( function ( mw ) { + var SliderView = mw.libs.revisionSlider.SliderView, + Slider = mw.libs.revisionSlider.Slider, + Revision = mw.libs.revisionSlider.Revision, + RevisionList = mw.libs.revisionSlider.RevisionList; QUnit.module( 'ext.RevisionSlider.SliderView' ); - // TODO FIX ME - // QUnit.test( 'render', function ( assert ) { - // var $container = $( '
' ), - // view = new SliderView( new Slider( [] ) ); - // - // view.render( $container ); - // assert.ok( $container.find( '.revision-slider' ).length > 0 ); - // } ); + QUnit.test( 'render', function ( assert ) { + var $container = $( '' ), + view = new SliderView( new Slider( new RevisionList( [ + new Revision( { size: 5, comment: 'Comment1', user: 'User1' } ), + new Revision( { size: 21, comment: 'Comment2', user: 'User2' } ), + new Revision( { size: 13, comment: 'Comment3', user: 'User3' } ) + ] ) ) ); + + view.render( $container ); + assert.ok( $container.find( '.revision-slider' ).length > 0 ); + } ); } )( mediaWiki );