Fix commented out tests

Change-Id: I283228cc03dcc64107720f9092a2f41483f74853
This commit is contained in:
addshore 2016-05-10 17:45:11 +01:00
parent 980f2ca917
commit cfac82978c
4 changed files with 61 additions and 56 deletions

View file

@ -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__,
];

View file

@ -1,5 +1,6 @@
( function ( mw, $ ) {
var RevisionList = function ( revs ) {
this.revisions = [];
this.initialize( revs );
this.view = new mw.libs.revisionSlider.RevisionListView( this );
};

View file

@ -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 );

View file

@ -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 = $( '<div/>' ),
// view = new SliderView( new Slider( [] ) );
//
// view.render( $container );
// assert.ok( $container.find( '.revision-slider' ).length > 0 );
// } );
QUnit.test( 'render', function ( assert ) {
var $container = $( '<div/>' ),
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 );