mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-12-18 10:51:10 +00:00
4b4fc6c6c9
- Hooking into mw.util.addPortlet - merged in tests from: I3258388d74c103515e3f0680304f9a376e439a35 possible follow-ups: - tooltips support - custom attributes support - Adapting portlets of types dropdown, tab to vector skin. Check patch set 10 for a starting point Depends-on: I79bad8661e34e653d41e6cb1cd4462ac5c6bc3b1 Bug: T303488 Change-Id: I35a51df6ece2e48e086e722337d4c6bba427eeb4
29 lines
1.1 KiB
JavaScript
29 lines
1.1 KiB
JavaScript
const portlets = require( '../../../resources/skins.vector.js/portlets.js' );
|
|
const mustache = require( 'mustache' );
|
|
const fs = require( 'fs' );
|
|
const menuTemplate = fs.readFileSync( 'includes/templates/Menu.mustache', 'utf8' );
|
|
const menuContentsTemplate = fs.readFileSync( 'includes/templates/MenuContents.mustache', 'utf8' );
|
|
|
|
describe( 'portlets', () => {
|
|
test( 'portlets that go through the hook method should match the menu template HTML', () => {
|
|
const id = 'foo';
|
|
const label = 'label text';
|
|
const portletHTML = mustache.render( menuTemplate, {
|
|
id, class: '', label: label
|
|
}, {
|
|
MenuContents: menuContentsTemplate
|
|
} );
|
|
|
|
const element = document.createElement( 'div' );
|
|
element.id = id;
|
|
if ( label ) {
|
|
const labelElement = document.createElement( 'label' );
|
|
labelElement.innerText = label;
|
|
element.appendChild( labelElement );
|
|
}
|
|
element.appendChild( document.createElement( 'ul' ) );
|
|
expect( portlets.addPortletHandler( element, label ).outerHTML.replace( /[\s\n]/gi, '' ) )
|
|
.toBe( portletHTML.replace( /[\s\n]/gi, '' ) );
|
|
} );
|
|
} );
|