2020-11-18 09:11:12 +00:00
|
|
|
QUnit.module( 'ext.RevisionSlider.DiffPage' );
|
|
|
|
|
2024-07-23 19:48:46 +00:00
|
|
|
QUnit.test( 'Push state', () => {
|
2023-06-22 09:41:37 +00:00
|
|
|
const SliderModule = require( 'ext.RevisionSlider.Slider' ),
|
2024-07-23 19:48:46 +00:00
|
|
|
DiffPage = SliderModule.DiffPage;
|
2023-06-22 09:41:37 +00:00
|
|
|
|
2024-07-23 19:48:46 +00:00
|
|
|
const historyStub = { pushState: sinon.spy() };
|
|
|
|
const sliderStub = { getOldestVisibleRevisionIndex: sinon.stub().returns( 42 ) };
|
|
|
|
const pointerStub = { getPosition: sinon.stub().returns( 5 ) };
|
|
|
|
const sliderViewStub = {
|
|
|
|
pointerOlder: pointerStub,
|
|
|
|
pointerNewer: pointerStub,
|
|
|
|
slider: sliderStub
|
|
|
|
};
|
|
|
|
const diffPage = new DiffPage( historyStub );
|
2016-06-29 10:43:46 +00:00
|
|
|
|
2020-11-18 09:11:12 +00:00
|
|
|
mw.config.set( {
|
|
|
|
wgDiffOldId: 1,
|
|
|
|
wgDiffNewId: 37
|
|
|
|
} );
|
|
|
|
|
2024-07-23 19:48:46 +00:00
|
|
|
diffPage.pushState( 3, 37, sliderViewStub );
|
2020-11-18 09:11:12 +00:00
|
|
|
|
2024-07-23 19:48:46 +00:00
|
|
|
sinon.assert.calledWith(
|
|
|
|
historyStub.pushState,
|
|
|
|
{ diff: 3, oldid: 37, pointerNewerPos: 5, pointerOlderPos: 5, sliderPos: 42 },
|
|
|
|
sinon.match.any,
|
|
|
|
sinon.match.any
|
2020-11-18 09:11:12 +00:00
|
|
|
);
|
2024-07-23 19:48:46 +00:00
|
|
|
|
|
|
|
sinon.assert.calledOnce( sliderStub.getOldestVisibleRevisionIndex );
|
|
|
|
sinon.assert.calledTwice( pointerStub.getPosition );
|
2020-11-18 09:11:12 +00:00
|
|
|
} );
|