2020-11-18 09:11:12 +00:00
|
|
|
QUnit.module( 'ext.RevisionSlider.DiffPage' );
|
|
|
|
|
|
|
|
QUnit.test( 'Push state', function ( assert ) {
|
2023-06-22 09:41:37 +00:00
|
|
|
const SliderModule = require( 'ext.RevisionSlider.Slider' ),
|
|
|
|
DiffPage = SliderModule.DiffPage,
|
|
|
|
SliderView = SliderModule.SliderView,
|
|
|
|
Slider = SliderModule.Slider,
|
|
|
|
RevisionList = SliderModule.RevisionList,
|
|
|
|
Revision = SliderModule.Revision;
|
|
|
|
|
|
|
|
const diffPage = new DiffPage(),
|
2020-11-18 09:11:12 +00:00
|
|
|
sliderView = new SliderView( new Slider( new RevisionList( [
|
|
|
|
new Revision( { revid: 1, comment: '' } ),
|
|
|
|
new Revision( { revid: 3, comment: '' } ),
|
|
|
|
new Revision( { revid: 37, comment: '' } )
|
|
|
|
] ) )
|
2016-06-29 10:43:46 +00:00
|
|
|
);
|
|
|
|
|
2020-11-18 09:11:12 +00:00
|
|
|
mw.config.set( {
|
|
|
|
wgDiffOldId: 1,
|
|
|
|
wgDiffNewId: 37
|
|
|
|
} );
|
|
|
|
sliderView.render( $( '<div>' ) );
|
|
|
|
|
2023-06-22 09:41:37 +00:00
|
|
|
const histLength = history.length;
|
2020-11-18 09:11:12 +00:00
|
|
|
|
|
|
|
diffPage.pushState( 3, 37, sliderView );
|
|
|
|
|
|
|
|
assert.strictEqual( history.length, histLength + 1 );
|
|
|
|
assert.propEqual(
|
|
|
|
history.state,
|
|
|
|
{
|
|
|
|
diff: 3,
|
|
|
|
oldid: 37,
|
|
|
|
pointerOlderPos: 1,
|
|
|
|
pointerNewerPos: 3,
|
|
|
|
sliderPos: NaN
|
|
|
|
}
|
|
|
|
);
|
|
|
|
} );
|