2020-09-14 20:46:26 +00:00
|
|
|
( function () {
|
|
|
|
var watchstar = require( '../../../resources/skins.minerva.scripts/watchstar.js' ),
|
|
|
|
toggleClasses = watchstar.test.toggleClasses,
|
|
|
|
WATCHED_CLASS = [ 'watched', 'mw-ui-icon-wikimedia-unStar-progressive' ],
|
|
|
|
TEMP_WATCHED_CLASS = [ 'temp-watched', 'mw-ui-icon-wikimedia-halfStar-progressive' ],
|
|
|
|
UNWATCHED_CLASS = 'mw-ui-icon-wikimedia-star-base20';
|
|
|
|
|
|
|
|
QUnit.module( 'Minerva Watchstar' );
|
|
|
|
|
|
|
|
function createElemWithClass( cssClass ) {
|
|
|
|
return $( '<div/>' ).addClass( cssClass );
|
|
|
|
}
|
|
|
|
|
|
|
|
QUnit.test( 'toggleClasses() from watched to unwatched', function ( assert ) {
|
|
|
|
var $elem = createElemWithClass( WATCHED_CLASS );
|
2021-12-08 21:08:18 +00:00
|
|
|
toggleClasses( $elem, false );
|
2020-09-14 20:46:26 +00:00
|
|
|
assert.deepEqual( $elem.attr( 'class' ), UNWATCHED_CLASS );
|
|
|
|
} );
|
|
|
|
|
|
|
|
QUnit.test( 'toggleClasses() from unwatched to watched', function ( assert ) {
|
|
|
|
var $elem = createElemWithClass( UNWATCHED_CLASS );
|
2021-12-08 21:08:18 +00:00
|
|
|
toggleClasses( $elem, true, null );
|
2020-09-14 20:46:26 +00:00
|
|
|
assert.deepEqual( $elem.attr( 'class' ).split( /\s+/ ), WATCHED_CLASS );
|
|
|
|
} );
|
|
|
|
|
|
|
|
QUnit.test( 'toggleClasses() from unwatched to temp watched', function ( assert ) {
|
|
|
|
var $elem = createElemWithClass( UNWATCHED_CLASS );
|
2021-12-08 21:08:18 +00:00
|
|
|
toggleClasses( $elem, true, 'expiry' );
|
2020-09-14 20:46:26 +00:00
|
|
|
assert.deepEqual( $elem.attr( 'class' ).split( /\s+/ ), TEMP_WATCHED_CLASS );
|
|
|
|
} );
|
|
|
|
|
|
|
|
QUnit.test( 'toggleClasses() from temp watched to watched', function ( assert ) {
|
|
|
|
var $elem = createElemWithClass( TEMP_WATCHED_CLASS );
|
2021-12-08 21:08:18 +00:00
|
|
|
toggleClasses( $elem, true, null );
|
2020-09-14 20:46:26 +00:00
|
|
|
assert.deepEqual( $elem.attr( 'class' ).split( /\s+/ ), WATCHED_CLASS );
|
|
|
|
} );
|
|
|
|
|
|
|
|
}() );
|