2020-11-18 09:11:12 +00:00
|
|
|
QUnit.module( 'ext.RevisionSlider.DiffPage' );
|
|
|
|
|
2024-06-08 04:13:35 +00:00
|
|
|
QUnit.test( 'Push state', ( 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
|
|
|
|
}
|
|
|
|
);
|
|
|
|
} );
|