2018-11-16 16:33:52 +00:00
|
|
|
( function () {
|
2016-06-29 10:43:46 +00:00
|
|
|
var DiffPage = mw.libs.revisionSlider.DiffPage,
|
|
|
|
SliderView = mw.libs.revisionSlider.SliderView,
|
|
|
|
Slider = mw.libs.revisionSlider.Slider,
|
2016-07-04 20:45:34 +00:00
|
|
|
RevisionList = mw.libs.revisionSlider.RevisionList,
|
|
|
|
Revision = mw.libs.revisionSlider.Revision;
|
2016-06-29 10:43:46 +00:00
|
|
|
|
2020-03-29 21:18:30 +00:00
|
|
|
QUnit.module( 'ext.RevisionSlider.DiffPage' );
|
2016-06-29 10:43:46 +00:00
|
|
|
|
|
|
|
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( [
|
2016-07-04 20:45:34 +00:00
|
|
|
new Revision( { revid: 1, comment: '' } ),
|
|
|
|
new Revision( { revid: 3, comment: '' } ),
|
|
|
|
new Revision( { revid: 37, comment: '' } )
|
2016-06-29 10:43:46 +00:00
|
|
|
] ) )
|
|
|
|
);
|
2017-07-18 15:52:10 +00:00
|
|
|
|
2018-09-04 08:52:16 +00:00
|
|
|
mw.config.set( {
|
|
|
|
wgDiffOldId: 1,
|
|
|
|
wgDiffNewId: 37
|
|
|
|
} );
|
2016-06-29 10:43:46 +00:00
|
|
|
sliderView.render( $( '<div>' ) );
|
|
|
|
|
|
|
|
histLength = history.length;
|
|
|
|
|
|
|
|
diffPage.pushState( 3, 37, sliderView );
|
|
|
|
|
2018-09-13 20:54:39 +00:00
|
|
|
assert.strictEqual( history.length, histLength + 1 );
|
2016-06-29 10:43:46 +00:00
|
|
|
assert.propEqual(
|
|
|
|
history.state,
|
|
|
|
{
|
2017-05-08 15:45:07 +00:00
|
|
|
diff: 3,
|
|
|
|
oldid: 37,
|
2016-06-29 10:43:46 +00:00
|
|
|
pointerOlderPos: 1,
|
|
|
|
pointerNewerPos: 3,
|
|
|
|
sliderPos: NaN
|
|
|
|
}
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
2018-11-16 16:33:52 +00:00
|
|
|
}() );
|