2023-08-08 23:33:28 +00:00
|
|
|
/* eslint-disable no-jquery/no-class-state */
|
2020-09-14 20:46:26 +00:00
|
|
|
( function () {
|
|
|
|
var watchstar = require( '../../../resources/skins.minerva.scripts/watchstar.js' ),
|
|
|
|
toggleClasses = watchstar.test.toggleClasses,
|
2023-08-08 23:33:28 +00:00
|
|
|
WATCHED_CLASS = watchstar.test.WATCHED_ICON_CLASS,
|
|
|
|
TEMP_WATCHED_CLASS = watchstar.test.TEMP_WATCHED_ICON_CLASS,
|
|
|
|
UNWATCHED_CLASS = watchstar.test.UNWATCHED_ICON_CLASS;
|
2020-09-14 20:46:26 +00:00
|
|
|
|
|
|
|
QUnit.module( 'Minerva Watchstar' );
|
|
|
|
|
2023-08-08 23:33:28 +00:00
|
|
|
function createElemWithClass( cssClass, iconClass ) {
|
|
|
|
const $icon = $( '<span>' ).addClass( `minerva-icon ${iconClass}` );
|
|
|
|
return $( '<div/>' ).addClass( cssClass ).append( $icon );
|
2020-09-14 20:46:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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 );
|
2023-08-08 23:33:28 +00:00
|
|
|
assert.true( $elem.find( '.minerva-icon' ).hasClass( UNWATCHED_CLASS ) );
|
2020-09-14 20:46:26 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
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 );
|
2023-08-08 23:33:28 +00:00
|
|
|
assert.true( $elem.find( '.minerva-icon' ).hasClass( WATCHED_CLASS ) );
|
2020-09-14 20:46:26 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
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' );
|
2023-08-08 23:33:28 +00:00
|
|
|
assert.true( $elem.find( '.minerva-icon' ).hasClass( TEMP_WATCHED_CLASS ) );
|
2020-09-14 20:46:26 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
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 );
|
2023-08-08 23:33:28 +00:00
|
|
|
assert.true( $elem.find( '.minerva-icon' ).hasClass( WATCHED_CLASS ) );
|
2020-09-14 20:46:26 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
}() );
|