mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-11-25 16:15:28 +00:00
a2c7c024df
Bug: T301254 Change-Id: I4469575ea8590ae22023b98c3dbd31bc672d5766
29 lines
919 B
JavaScript
29 lines
919 B
JavaScript
const { test } = require( '../../../resources/skins.vector.es6/main.js' );
|
|
|
|
describe( 'main.js', () => {
|
|
it( 'getHeadingIntersectionHandler', () => {
|
|
const section = document.createElement( 'div' );
|
|
section.setAttribute( 'class', 'mw-body-content' );
|
|
section.setAttribute( 'id', 'mw-content-text' );
|
|
const heading = document.createElement( 'h2' );
|
|
const headline = document.createElement( 'span' );
|
|
headline.classList.add( 'mw-headline' );
|
|
headline.setAttribute( 'id', 'headline' );
|
|
heading.appendChild( headline );
|
|
section.appendChild(
|
|
heading
|
|
);
|
|
|
|
[
|
|
[ section, 'toc-mw-content-text' ],
|
|
[ heading, 'toc-headline' ]
|
|
].forEach( ( testCase ) => {
|
|
const node = /** @type {HTMLElement} */ ( testCase[ 0 ] );
|
|
const fn = jest.fn();
|
|
const handler = test.getHeadingIntersectionHandler( fn );
|
|
handler( node );
|
|
expect( fn ).toHaveBeenCalledWith( testCase[ 1 ] );
|
|
} );
|
|
} );
|
|
} );
|