mediawiki-extensions-Revisi.../tests/qunit/RevisionSlider.DiffPage.test.js
Leszek Manicki 8e2365502b Make RevisionList expect list of Revision object
Despite its documentation the "constructor" of RevisionList tends
to expect array of revision data in a format returned by API instead
of array of Revision objects.
Due to different name of ID fields in Revision object and in API array,
if "real" Revision object is passed to RevisionList, its ID is lost.

This changes RevisionList so that it only accepts an array of Revision
objects. This provides better abstraction.

This is basically a revert of I147270f28381038d05f8bcfd2317e8c269b2e458
which aimed at the same problem but suggested solution doesn't seem right.

Change-Id: Ic45cdd3e7b707a8c6a19eecf0a84d4c11696cd1f
2016-07-05 00:01:46 +02:00

45 lines
1.1 KiB
JavaScript

( function ( mw ) {
var DiffPage = mw.libs.revisionSlider.DiffPage,
SliderView = mw.libs.revisionSlider.SliderView,
Slider = mw.libs.revisionSlider.Slider,
RevisionList = mw.libs.revisionSlider.RevisionList,
Revision = mw.libs.revisionSlider.Revision;
QUnit.module( 'ext.RevisionSlider.DiffPage' );
QUnit.test( 'Initialize DiffPage', function ( assert ) {
assert.ok( ( new DiffPage() ) );
} );
QUnit.test( 'Push state', function ( assert ) {
var histLength,
diffPage = new DiffPage(),
sliderView = new SliderView( new Slider( new RevisionList( [
new Revision( { revid: 1, comment: '' } ),
new Revision( { revid: 3, comment: '' } ),
new Revision( { revid: 37, comment: '' } )
] ) )
);
mw.config.values.extRevisionSliderOldRev = 1;
mw.config.values.extRevisionSliderNewRev = 37;
sliderView.render( $( '<div>' ) );
histLength = history.length;
diffPage.pushState( 3, 37, sliderView );
assert.equal( history.length, histLength + 1 );
assert.propEqual(
history.state,
{
revid1: 3,
revid2: 37,
pointerOlderPos: 1,
pointerNewerPos: 3,
sliderPos: NaN
}
);
} );
} )( mediaWiki );