mediawiki-skins-Vector/tests/jest/skins.vector.js/menuTabs.test.js
Jon Robson 2499e834bb Remove Eslint disable and TypeScript ignore rules, bump coverage
Follow up to 87dd101a
* bump coverage to reflect improved test state
* remove ts-ignore statements
* Drop eslint-disable-next-line compat/compat rules in ES6 code
* Drop TypeScript checking on Jest files
* Identifies an existing usage of ES7 includes method in place
where ES6 browsers need to be supported.
* Update App.vue booleans to default to false. Note this doesn't
impact our usage of the search app as we always pass these values
in.
* Drop unused eslintEs6.json configuration file

Change-Id: Ib6f1ef77bf4e27ecdcc54b5fb963818437f8195c
2023-04-13 00:20:44 +00:00

74 lines
1.8 KiB
JavaScript

const menuTabs = require( '../../../resources/skins.vector.js/menuTabs.js' );
describe( 'menuTabs', () => {
beforeEach( () => {
/** @type {Function} */
let callback;
jest.spyOn( mw, 'hook' ).mockImplementation( () => {
return {
add: function ( fn ) {
callback = fn;
return this;
},
fire: ( data ) => {
if ( callback ) {
callback( data );
}
}
};
} );
} );
afterEach( () => {
jest.restoreAllMocks();
} );
test( 'adds vector-tab-noicon class to li element when part of tabs', () => {
document.body.innerHTML = `
<div id="p-views" class="vector-menu mw-portlet mw-portlet-views vector-menu-tabs">
<div class="vector-menu-content">
<ul class="vector-menu-content-list">
<li class="mw-list-item mw-list-item-js" id="test-id">
<a href="#test-href">
<span>
test link content
</span>
</a>
</li>
</ul>
</div>
</div>
`;
const menuItem = document.getElementById( 'test-id' );
menuTabs();
mw.hook( 'util' ).fire( menuItem, { id: 'test-id' } );
expect( document.body.innerHTML ).toMatchSnapshot();
} );
test( 'does not add vector-tab-noicon class to li element when not part of tabs', () => {
document.body.innerHTML = `
<div id="p-variants" class="vector-menu mw-portlet mw-portlet-variants vector-menu-dropdown">
<div class="vector-menu-content">
<ul class="vector-menu-content-list">
<li class="mw-list-item mw-list-item-js" id="test-id">
<a href="#test-href">
<span>
test link content
</span>
</a>
</li>
</ul>
</div>
</div>
`;
const menuItem = document.getElementById( 'test-id' );
menuTabs();
mw.hook( 'util' ).fire( menuItem, { id: 'test-id' } );
expect( document.body.innerHTML ).toMatchSnapshot();
} );
} );