mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/RevisionSlider
synced 2024-11-14 19:24:42 +00:00
Fix commented out tests
Change-Id: I283228cc03dcc64107720f9092a2f41483f74853
This commit is contained in:
parent
980f2ca917
commit
cfac82978c
|
@ -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__,
|
||||
];
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
( function ( mw, $ ) {
|
||||
var RevisionList = function ( revs ) {
|
||||
this.revisions = [];
|
||||
this.initialize( revs );
|
||||
this.view = new mw.libs.revisionSlider.RevisionListView( this );
|
||||
};
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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 );
|
||||
|
|
Loading…
Reference in a new issue