mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/RevisionSlider
synced 2024-11-15 03:33:45 +00:00
0251b952cb
Current rendering test passes but not really because test results meet expectations but rather by accident. Test revisions lacked ids, and current way of rendering revision made all revision bars have id equal to "undefined" string. That made test pass, although it is not what is expected (we expect three revisions in tests but not that three revisions have the same id, and each of them gets a pointer assigned to - the might look interesting in the browser, though). Also the test will fail as soon as the way of rendering revisions is switched to standard use of jquery's attr() instead of handcrafting the HTML in the RevisionListView class. This patch adds missing IDs to test Revisions where needed, and also set config vars that are required to render Slider properly. This also adds tests for cases where the exception is thrown. This also makes RevisionList initialization consistent. RevisionList expect to receive an array of revision data in a format that API returns. Tests provided arrays of Revision objects instead. That also works with a difference that API-like format uses "revid" as a field containing revision ID, while Revision objects use a field named "id". The way RevisionList was used in tests actually lead to have each revision initialized twice, and on the second initialization it lost its ID (due to field name difference). This changes test to provide a API-like array instead of arrays of Revision objects to RevisionList. Change-Id: I147270f28381038d05f8bcfd2317e8c269b2e458
28 lines
720 B
JavaScript
28 lines
720 B
JavaScript
( function ( mw ) {
|
|
var RevisionList = mw.libs.revisionSlider.RevisionList;
|
|
|
|
QUnit.module( 'ext.RevisionSlider.RevisionList' );
|
|
|
|
QUnit.test( 'Find biggest Revision', function ( assert ) {
|
|
var revs = new RevisionList( [
|
|
{ size: 5 },
|
|
{ size: 21 },
|
|
{ size: 13 }
|
|
] );
|
|
|
|
assert.equal( revs.getBiggestChangeSize(), 16 );
|
|
} );
|
|
|
|
QUnit.test( 'calculate relative size on init', function ( assert ) {
|
|
var revs = new RevisionList( [
|
|
{ size: 5 },
|
|
{ size: 21 },
|
|
{ size: 13 }
|
|
] );
|
|
|
|
assert.equal( revs.getRevisions()[ 0 ].getRelativeSize(), 5 );
|
|
assert.equal( revs.getRevisions()[ 1 ].getRelativeSize(), 16 );
|
|
assert.equal( revs.getRevisions()[ 2 ].getRelativeSize(), -8 );
|
|
} );
|
|
} )( mediaWiki );
|