mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-12-19 03:10:47 +00:00
87959c8a59
In preparation for 856718 where pinnableElement.js makes use of features.js, move features.js and limitedWidthToggle.js out of the skins.vector.js module and into the skins.vector.es6 module. This will make it easier to use by pinnableElement.js without needing the es6 module to depend on the es5 module. This does have the negative side-effect of causing the limited width feature to not be supported by IE11 (and other non-ES6 browsers), however this tradeoff was discussed with our product manager to be acceptable. Additionally, this maintains the status quo as the toggle button does not currently show in IE11 (which may be a bug). Bug: T322051 Change-Id: If0e8cb98deabe847c2cc71fddb90ca36d15e5f8f
35 lines
915 B
JavaScript
35 lines
915 B
JavaScript
const features = require( '../../../resources/skins.vector.es6/features.js' );
|
|
|
|
describe( 'features', () => {
|
|
beforeEach( () => {
|
|
document.body.setAttribute( 'class', 'vector-feature-foo-disabled vector-feature-bar-enabled hello' );
|
|
} );
|
|
|
|
test( 'toggle', () => {
|
|
features.toggle( 'foo' );
|
|
features.toggle( 'bar' );
|
|
|
|
expect(
|
|
document.body.classList.contains( 'vector-feature-foo-enabled' )
|
|
).toBe( true );
|
|
expect(
|
|
document.body.classList.contains( 'vector-feature-foo-disabled' )
|
|
).toBe( false );
|
|
expect(
|
|
document.body.classList.contains( 'vector-feature-bar-disabled' )
|
|
).toBe( true );
|
|
expect(
|
|
document.body.classList.contains( 'vector-feature-bar-enabled' )
|
|
).toBe( false );
|
|
expect(
|
|
document.body.classList.contains( 'hello' )
|
|
).toBe( true );
|
|
} );
|
|
|
|
test( 'toggle unknown feature', () => {
|
|
expect( () => {
|
|
features.toggle( 'unknown' );
|
|
} ).toThrow();
|
|
} );
|
|
} );
|