mediawiki-extensions-Revisi.../tests/RevisionSlider.Revision.test.js
Jakob Warkotsch 139368093e Adds the missing first revision to the slider.
The first revision was previously not included because revision size was
calculated by subtracting the size in bytes of a revision from the size
of the previous revision which lead to a problem with the first
revision. The first revision's relative size is now equal to its actual
size.

Bug: T135003
Change-Id: I71441ed33673b06407be0fc566c96c3955dddbf9
2016-05-12 15:25:37 +00:00

47 lines
1.3 KiB
JavaScript

( function ( mw ) {
QUnit.module( 'ext.RevisionSlider.Revision' );
QUnit.test( 'create Revision', function ( assert ) {
var data = {
size: 5,
comment: 'hello',
parsedcomment: '<b>hello</b>',
timestamp: '2016-04-26T10:27:14Z', // 10:27, 26 Apr 2016
user: 'meh'
},
rev = new mw.libs.revisionSlider.Revision( data );
assert.equal( rev.getSize(), data.size );
assert.equal( rev.getComment(), data.comment );
assert.equal( rev.getParsedComment(), data.parsedcomment );
assert.equal( rev.getFormattedDate(), '10:27, 26 Apr 2016' );
assert.equal( rev.getUser(), data.user );
} );
QUnit.test( 'get Revision with section', function ( assert ) {
var data = {
comment: '/* section */ comment'
},
rev = new mw.libs.revisionSlider.Revision( data );
assert.equal( rev.getSection(), 'section' );
} );
QUnit.test( 'get Revision without section', function ( assert ) {
var data = {
comment: 'no section comment'
},
rev = new mw.libs.revisionSlider.Revision( data );
assert.equal( rev.getSection(), '' );
} );
QUnit.test( 'get and set relative size', function ( assert ) {
var size = 5,
rev = new mw.libs.revisionSlider.Revision( {} );
rev.setRelativeSize( size );
assert.equal( rev.getRelativeSize(), size );
} );
} )( mediaWiki );