mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/RevisionSlider
synced 2024-12-19 10:20:53 +00:00
b900446572
Reintroduces IIFE closures in test files because variables were declared in the global namespace, and "const" now causes hard errors. Bug: T339323 Change-Id: I69e9d7a29591137f185f3e5ab02dea590ec4dff6
41 lines
971 B
JavaScript
41 lines
971 B
JavaScript
QUnit.module( 'ext.RevisionSlider.DiffPage' );
|
|
|
|
QUnit.test( 'Push state', function ( assert ) {
|
|
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(),
|
|
sliderView = new SliderView( new Slider( new RevisionList( [
|
|
new Revision( { revid: 1, comment: '' } ),
|
|
new Revision( { revid: 3, comment: '' } ),
|
|
new Revision( { revid: 37, comment: '' } )
|
|
] ) )
|
|
);
|
|
|
|
mw.config.set( {
|
|
wgDiffOldId: 1,
|
|
wgDiffNewId: 37
|
|
} );
|
|
sliderView.render( $( '<div>' ) );
|
|
|
|
const histLength = history.length;
|
|
|
|
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
|
|
}
|
|
);
|
|
} );
|