2023-08-08 23:33:28 +00:00
|
|
|
/* eslint-disable no-jquery/no-class-state */
|
2020-09-14 20:46:26 +00:00
|
|
|
( function () {
|
2024-03-24 20:53:43 +00:00
|
|
|
const watchstar = require( '../../../resources/skins.minerva.scripts/watchstar.js' );
|
|
|
|
const toggleClasses = watchstar.test.toggleClasses;
|
|
|
|
const WATCHED_CLASS = watchstar.test.WATCHED_ICON_CLASS;
|
|
|
|
const TEMP_WATCHED_CLASS = watchstar.test.TEMP_WATCHED_ICON_CLASS;
|
|
|
|
const 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 ) {
|
2024-01-24 22:02:12 +00:00
|
|
|
const $icon = $( '<span>' ).addClass( `minerva-icon ${ iconClass }` );
|
2024-03-29 09:27:19 +00:00
|
|
|
return $( '<div>' ).addClass( cssClass ).append( $icon );
|
2020-09-14 20:46:26 +00:00
|
|
|
}
|
|
|
|
|
2024-06-03 12:06:43 +00:00
|
|
|
QUnit.test( 'toggleClasses() from watched to unwatched', ( assert ) => {
|
2024-03-24 20:53:43 +00:00
|
|
|
const $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
|
|
|
} );
|
|
|
|
|
2024-06-03 12:06:43 +00:00
|
|
|
QUnit.test( 'toggleClasses() from unwatched to watched', ( assert ) => {
|
2024-03-24 20:53:43 +00:00
|
|
|
const $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
|
|
|
} );
|
|
|
|
|
2024-06-03 12:06:43 +00:00
|
|
|
QUnit.test( 'toggleClasses() from unwatched to temp watched', ( assert ) => {
|
2024-03-24 20:53:43 +00:00
|
|
|
const $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
|
|
|
} );
|
|
|
|
|
2024-06-03 12:06:43 +00:00
|
|
|
QUnit.test( 'toggleClasses() from temp watched to watched', ( assert ) => {
|
2024-03-24 20:53:43 +00:00
|
|
|
const $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
|
|
|
} );
|
|
|
|
|
|
|
|
}() );
|