mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-15 11:46:55 +00:00
807100bcca
Enforce it with eslint. Ignore: * Comment lines with eslint disable directives * QUnit test lines as they contain long subjects (QUnit.* (only, test, module, skip, etc) * Strings, since long strings are used extensively in tests * Ignore template literals for similar reasons * Regex literals as they may be too long, but can't be easily split in several lines * Long urls See bug for more general proposal for eslint-wikimedia-config. Bug: T185295 Change-Id: I3aacaf46e61a4d96547c513073e179ef997deb09
71 lines
1.6 KiB
JavaScript
71 lines
1.6 KiB
JavaScript
import * as counts from '../../src/counts';
|
|
|
|
QUnit.module( 'ext.popups/counts' );
|
|
|
|
QUnit.test( '#getEditCountBucket', function ( assert ) {
|
|
var i, bucket, count,
|
|
cases = [
|
|
[ 0, '0 edits' ],
|
|
[ 1, '1-4 edits' ],
|
|
[ 2, '1-4 edits' ],
|
|
[ 4, '1-4 edits' ],
|
|
[ 5, '5-99 edits' ],
|
|
[ 25, '5-99 edits' ],
|
|
[ 50, '5-99 edits' ],
|
|
[ 99, '5-99 edits' ],
|
|
[ 100, '100-999 edits' ],
|
|
[ 101, '100-999 edits' ],
|
|
[ 500, '100-999 edits' ],
|
|
[ 999, '100-999 edits' ],
|
|
[ 1000, '1000+ edits' ],
|
|
[ 1500, '1000+ edits' ]
|
|
];
|
|
|
|
assert.expect( cases.length );
|
|
|
|
for ( i = 0; i < cases.length; i++ ) {
|
|
count = cases[ i ][ 0 ];
|
|
bucket = counts.getEditCountBucket( count );
|
|
assert.equal(
|
|
bucket,
|
|
cases[ i ][ 1 ],
|
|
'Edit count bucket is "' + bucket + '" when edit count is ' + count + '.'
|
|
);
|
|
}
|
|
} );
|
|
|
|
QUnit.test( '#getPreviewCountBucket', function ( assert ) {
|
|
var i, count, bucket,
|
|
cases = [
|
|
[ false, 'unknown' ],
|
|
[ NaN, 'unknown' ],
|
|
[ undefined, 'unknown' ],
|
|
[ null, 'unknown' ],
|
|
[ '', 'unknown' ],
|
|
[ -1, 'unknown' ],
|
|
[ 0, '0 previews' ],
|
|
[ 1, '1-4 previews' ],
|
|
[ 2, '1-4 previews' ],
|
|
[ 4, '1-4 previews' ],
|
|
[ 5, '5-20 previews' ],
|
|
[ 10, '5-20 previews' ],
|
|
[ 20, '5-20 previews' ],
|
|
[ 21, '21+ previews' ],
|
|
[ 100, '21+ previews' ],
|
|
[ 1000, '21+ previews' ]
|
|
];
|
|
|
|
assert.expect( cases.length );
|
|
|
|
for ( i = 0; i < cases.length; i++ ) {
|
|
count = cases[ i ][ 0 ];
|
|
bucket = counts.getPreviewCountBucket( count );
|
|
assert.equal(
|
|
bucket,
|
|
cases[ i ][ 1 ],
|
|
'Preview count bucket is "' +
|
|
bucket + '" when preview count is ' + count + '.'
|
|
);
|
|
}
|
|
} );
|