2016-12-13 10:25:17 +00:00
|
|
|
( function ( mw ) {
|
|
|
|
|
|
|
|
QUnit.module( 'ext.popups/reducers#settings' );
|
|
|
|
|
|
|
|
QUnit.test( '@@INIT', function ( assert ) {
|
|
|
|
var state = mw.popups.reducers.settings( undefined, { type: '@@INIT' } );
|
|
|
|
|
|
|
|
assert.deepEqual(
|
|
|
|
state,
|
|
|
|
{
|
2016-12-13 18:04:03 +00:00
|
|
|
shouldShow: false,
|
|
|
|
showHelp: false
|
2016-12-13 10:25:17 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
|
|
|
QUnit.test( 'SETTINGS_SHOW', function ( assert ) {
|
|
|
|
assert.expect( 1 );
|
|
|
|
|
|
|
|
assert.deepEqual(
|
|
|
|
mw.popups.reducers.settings( {}, { type: 'SETTINGS_SHOW' } ),
|
|
|
|
{
|
2016-12-13 18:04:03 +00:00
|
|
|
shouldShow: true,
|
|
|
|
showHelp: false
|
2016-12-13 10:25:17 +00:00
|
|
|
},
|
2016-12-13 18:04:03 +00:00
|
|
|
'It should mark the settings dialog as ready to be shown, with no help.'
|
2016-12-13 10:25:17 +00:00
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
|
|
|
QUnit.test( 'SETTINGS_HIDE', function ( assert ) {
|
|
|
|
assert.expect( 1 );
|
|
|
|
|
|
|
|
assert.deepEqual(
|
|
|
|
mw.popups.reducers.settings( {}, { type: 'SETTINGS_HIDE' } ),
|
|
|
|
{
|
2016-12-13 18:04:03 +00:00
|
|
|
shouldShow: false,
|
|
|
|
showHelp: false
|
2016-12-13 10:25:17 +00:00
|
|
|
},
|
2016-12-13 18:04:03 +00:00
|
|
|
'It should mark the settings dialog as ready to be closed, and hide help.'
|
2016-12-13 10:25:17 +00:00
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
2016-12-13 18:04:03 +00:00
|
|
|
QUnit.test( 'SETTINGS_CHANGE', function ( assert ) {
|
|
|
|
var action = function ( wasEnabled, enabled ) {
|
|
|
|
return {
|
|
|
|
type: 'SETTINGS_CHANGE',
|
|
|
|
wasEnabled: wasEnabled,
|
|
|
|
enabled: enabled
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
assert.deepEqual(
|
|
|
|
mw.popups.reducers.settings( {}, action( false, false ) ),
|
|
|
|
{ shouldShow: false },
|
|
|
|
'It should just hide the settings dialog when enabled state stays the same.'
|
|
|
|
);
|
|
|
|
assert.deepEqual(
|
|
|
|
mw.popups.reducers.settings( {}, action( true, true ) ),
|
|
|
|
{ shouldShow: false },
|
|
|
|
'It should just hide the settings dialog when enabled state stays the same.'
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.deepEqual(
|
|
|
|
mw.popups.reducers.settings( {}, action( false, true ) ),
|
|
|
|
{
|
|
|
|
shouldShow: false,
|
|
|
|
showHelp: false
|
|
|
|
},
|
|
|
|
'It should hide the settings dialog and help when we enable.'
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.deepEqual(
|
|
|
|
mw.popups.reducers.settings( {}, action( true, false ) ),
|
|
|
|
{
|
|
|
|
shouldShow: true,
|
|
|
|
showHelp: true
|
|
|
|
},
|
|
|
|
'It should keep the settings showing and show the help when we disable.'
|
|
|
|
);
|
|
|
|
|
|
|
|
} );
|
|
|
|
|
2016-12-13 10:25:17 +00:00
|
|
|
}( mediaWiki ) );
|