mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-12-12 07:55:21 +00:00
0eb8811e7a
* Introduce a generalized feature toggle system that uses user preferences or localStorage for anons (right now the latter is out of scope but will be explored in a follow up) * Feature flagged to VisualEnhancementNext for now, given the dependency on icon size Bug: T319449 Change-Id: I7343a3f38b720411d5ef5f3414f25f475b0bb84a
35 lines
914 B
JavaScript
35 lines
914 B
JavaScript
const features = require( '../../../resources/skins.vector.js/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();
|
|
} );
|
|
} );
|