2023-06-22 09:41:37 +00:00
|
|
|
( function () {
|
|
|
|
const SliderModule = require( 'ext.RevisionSlider.Slider' ),
|
|
|
|
Revision = SliderModule.Revision;
|
|
|
|
|
|
|
|
QUnit.module( 'ext.RevisionSlider.Revision' );
|
|
|
|
|
|
|
|
QUnit.test( 'create Revision', function ( assert ) {
|
|
|
|
const data = {
|
|
|
|
size: 5,
|
|
|
|
parsedcomment: '<b>hello</b>',
|
|
|
|
timestamp: '2016-04-26T10:27:14Z', // 10:27, 26 Apr 2016
|
|
|
|
user: 'meh',
|
|
|
|
userGender: 'female'
|
|
|
|
},
|
|
|
|
rev = new Revision( data );
|
|
|
|
|
|
|
|
SliderModule.setUserOffset( 0 );
|
|
|
|
|
|
|
|
assert.strictEqual( rev.getSize(), data.size );
|
|
|
|
assert.strictEqual( rev.getParsedComment(), data.parsedcomment );
|
|
|
|
assert.strictEqual( rev.getUser(), data.user );
|
|
|
|
assert.strictEqual( rev.getUserGender(), 'female' );
|
|
|
|
assert.false( rev.isMinor() );
|
|
|
|
|
|
|
|
if ( mw.config.get( 'wgUserLanguage' ) === 'en' ) {
|
|
|
|
assert.strictEqual( rev.getFormattedDate(), '26 April 2016 10:27 AM' );
|
|
|
|
}
|
2016-05-12 12:00:00 +00:00
|
|
|
} );
|
|
|
|
|
2023-06-22 09:41:37 +00:00
|
|
|
QUnit.test( 'isMinor with minor empty string', function ( assert ) {
|
|
|
|
const rev = new Revision( {
|
|
|
|
minor: ''
|
|
|
|
} );
|
2016-05-12 16:01:50 +00:00
|
|
|
|
2023-06-22 09:41:37 +00:00
|
|
|
assert.true( rev.isMinor() );
|
2016-04-28 10:18:52 +00:00
|
|
|
} );
|
|
|
|
|
2023-06-22 09:41:37 +00:00
|
|
|
QUnit.test( 'isMinor with minor true', function ( assert ) {
|
|
|
|
const rev = new Revision( {
|
|
|
|
minor: true
|
|
|
|
} );
|
2016-05-12 16:01:50 +00:00
|
|
|
|
2023-06-22 09:41:37 +00:00
|
|
|
assert.true( rev.isMinor() );
|
|
|
|
} );
|
2016-05-12 16:01:50 +00:00
|
|
|
|
2023-06-22 09:41:37 +00:00
|
|
|
QUnit.test( 'get and set relative size', function ( assert ) {
|
|
|
|
const size = 5,
|
|
|
|
rev = new Revision( {} );
|
|
|
|
rev.setRelativeSize( size );
|
|
|
|
assert.strictEqual( rev.getRelativeSize(), size );
|
2020-11-18 09:11:12 +00:00
|
|
|
} );
|
2016-05-12 16:01:50 +00:00
|
|
|
|
2023-06-22 09:41:37 +00:00
|
|
|
QUnit.revisionSlider.testOrSkip( 'getFormattedDate, offset: 0', function ( assert ) {
|
|
|
|
const rev = new Revision( {
|
|
|
|
timestamp: '2016-04-26T10:27:14Z' // 10:27, 26 Apr 2016
|
|
|
|
} );
|
2016-05-12 16:01:50 +00:00
|
|
|
|
2023-06-22 09:41:37 +00:00
|
|
|
SliderModule.setUserOffset( 0 );
|
2016-05-12 16:01:50 +00:00
|
|
|
|
2023-06-22 09:41:37 +00:00
|
|
|
assert.strictEqual( rev.getFormattedDate(), '26 April 2016 10:27 AM' );
|
|
|
|
}, mw.config.get( 'wgUserLanguage' ) !== 'en' );
|
2016-05-12 16:01:50 +00:00
|
|
|
|
2023-06-22 09:41:37 +00:00
|
|
|
QUnit.revisionSlider.testOrSkip( 'getFormattedDate, offset: 120 (treat as hours, +2h)', function ( assert ) {
|
|
|
|
const rev = new Revision( {
|
|
|
|
timestamp: '2016-04-26T10:27:14Z' // 10:27, 26 Apr 2016
|
|
|
|
} );
|
2016-05-12 16:01:50 +00:00
|
|
|
|
2023-06-22 09:41:37 +00:00
|
|
|
// Berlin = 120
|
|
|
|
SliderModule.setUserOffset( 120 );
|
2016-05-12 16:01:50 +00:00
|
|
|
|
2023-06-22 09:41:37 +00:00
|
|
|
assert.strictEqual( rev.getFormattedDate(), '26 April 2016 12:27 PM' );
|
|
|
|
}, mw.config.get( 'wgUserLanguage' ) !== 'en' );
|
2016-05-12 16:01:50 +00:00
|
|
|
|
2023-06-22 09:41:37 +00:00
|
|
|
QUnit.revisionSlider.testOrSkip( 'getFormattedDate, negative offset: -420 (treat as hours, -7h)', function ( assert ) {
|
|
|
|
const rev = new Revision( {
|
|
|
|
timestamp: '2016-04-26T10:27:14Z' // 10:27, 26 Apr 2016
|
|
|
|
} );
|
2016-05-12 16:01:50 +00:00
|
|
|
|
2023-06-22 09:41:37 +00:00
|
|
|
// San Francisco = -420
|
|
|
|
SliderModule.setUserOffset( -420 );
|
2016-05-30 12:36:48 +00:00
|
|
|
|
2023-06-22 09:41:37 +00:00
|
|
|
assert.strictEqual( rev.getFormattedDate(), '26 April 2016 3:27 AM' );
|
|
|
|
}, mw.config.get( 'wgUserLanguage' ) !== 'en' );
|
|
|
|
}() );
|