2020-03-29 20:36:10 +00:00
|
|
|
var SliderModule = require( 'ext.RevisionSlider.Slider' ),
|
|
|
|
DiffPage = SliderModule.DiffPage,
|
|
|
|
SliderView = SliderModule.SliderView,
|
|
|
|
Slider = SliderModule.Slider,
|
2020-03-29 21:15:32 +00:00
|
|
|
RevisionList = require( 'ext.RevisionSlider.RevisionList' ).RevisionList,
|
|
|
|
Revision = require( 'ext.RevisionSlider.RevisionList' ).Revision;
|
2020-11-18 09:11:12 +00:00
|
|
|
|
|
|
|
QUnit.module( 'ext.RevisionSlider.DiffPage' );
|
|
|
|
|
|
|
|
QUnit.test( 'Initialize DiffPage', function ( assert ) {
|
|
|
|
assert.ok( ( new DiffPage() ) );
|
|
|
|
} );
|
|
|
|
|
|
|
|
QUnit.test( 'Push state', function ( assert ) {
|
2021-10-07 13:55:44 +00:00
|
|
|
var 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>' ) );
|
|
|
|
|
2021-10-07 13:55:44 +00:00
|
|
|
var 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
|
|
|
|
}
|
|
|
|
);
|
|
|
|
} );
|