2017-07-28 17:32:46 +00:00
|
|
|
import * as counts from '../../src/counts';
|
2017-02-01 11:09:42 +00:00
|
|
|
|
|
|
|
QUnit.module( 'ext.popups/counts' );
|
|
|
|
|
2018-03-14 23:50:09 +00:00
|
|
|
QUnit.test( '#getEditCountBucket', ( assert ) => {
|
2018-03-19 19:39:41 +00:00
|
|
|
const 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' ]
|
|
|
|
];
|
2017-02-01 11:09:42 +00:00
|
|
|
|
2018-05-08 19:48:17 +00:00
|
|
|
assert.expect( cases.length, 'All assertions are executed.' );
|
2017-02-01 11:09:42 +00:00
|
|
|
|
2018-03-19 19:39:41 +00:00
|
|
|
for ( let i = 0; i < cases.length; i++ ) {
|
|
|
|
const count = cases[ i ][ 0 ];
|
|
|
|
const bucket = counts.getEditCountBucket( count );
|
2018-05-20 12:32:51 +00:00
|
|
|
assert.strictEqual(
|
2017-02-01 11:09:42 +00:00
|
|
|
bucket,
|
|
|
|
cases[ i ][ 1 ],
|
2018-03-20 17:01:18 +00:00
|
|
|
`Edit count bucket is "${ bucket }" when edit count is ${ count }.`
|
2017-02-01 11:09:42 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
2018-03-14 23:50:09 +00:00
|
|
|
QUnit.test( '#getPreviewCountBucket', ( assert ) => {
|
2018-03-19 19:39:41 +00:00
|
|
|
const 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' ]
|
|
|
|
];
|
2017-02-01 11:09:42 +00:00
|
|
|
|
2018-05-08 19:48:17 +00:00
|
|
|
assert.expect( cases.length, 'All assertions are executed.' );
|
2017-02-01 11:09:42 +00:00
|
|
|
|
2018-03-19 19:39:41 +00:00
|
|
|
for ( let i = 0; i < cases.length; i++ ) {
|
|
|
|
const count = cases[ i ][ 0 ];
|
|
|
|
const bucket = counts.getPreviewCountBucket( count );
|
2018-05-20 12:32:51 +00:00
|
|
|
assert.strictEqual(
|
2017-02-01 11:09:42 +00:00
|
|
|
bucket,
|
|
|
|
cases[ i ][ 1 ],
|
2018-03-20 17:01:18 +00:00
|
|
|
`Preview count bucket is "${ bucket }" when preview count is ${ count }.`
|
2017-02-01 11:09:42 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
} );
|