2017-07-28 17:32:46 +00:00
|
|
|
import settings from '../../../src/reducers/settings';
|
2018-07-13 15:12:49 +00:00
|
|
|
import actionTypes from '../../../src/actionTypes';
|
2017-02-01 11:09:42 +00:00
|
|
|
|
|
|
|
QUnit.module( 'reducers/settings' );
|
|
|
|
|
2018-03-14 23:50:09 +00:00
|
|
|
QUnit.test( '@@INIT', ( assert ) => {
|
2018-03-19 19:39:41 +00:00
|
|
|
const state = settings( undefined, { type: '@@INIT' } );
|
2017-02-01 11:09:42 +00:00
|
|
|
|
|
|
|
assert.deepEqual(
|
|
|
|
state,
|
|
|
|
{
|
|
|
|
shouldShow: false,
|
|
|
|
showHelp: false,
|
|
|
|
shouldShowFooterLink: false
|
2018-05-08 19:48:17 +00:00
|
|
|
},
|
|
|
|
'The initial state doesn\'t show, doesn\'t show help, and doesn\'t show a footer link.'
|
2017-02-01 11:09:42 +00:00
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
2018-03-14 23:50:09 +00:00
|
|
|
QUnit.test( 'BOOT', ( assert ) => {
|
2018-03-19 19:39:41 +00:00
|
|
|
const action = {
|
2018-07-13 15:12:49 +00:00
|
|
|
type: actionTypes.BOOT,
|
2021-04-07 10:23:05 +00:00
|
|
|
initiallyEnabled: { page: false },
|
2017-02-01 11:09:42 +00:00
|
|
|
user: {
|
|
|
|
isAnon: true
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
assert.deepEqual(
|
|
|
|
settings( {}, action ),
|
|
|
|
{
|
|
|
|
shouldShowFooterLink: true
|
2018-05-08 19:48:17 +00:00
|
|
|
},
|
|
|
|
'The boot state shows a footer link.'
|
2017-02-01 11:09:42 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// ---
|
|
|
|
|
|
|
|
// And when the user is logged out...
|
|
|
|
action.user.isAnon = false;
|
|
|
|
|
|
|
|
assert.deepEqual(
|
|
|
|
settings( {}, action ),
|
|
|
|
{
|
|
|
|
shouldShowFooterLink: false
|
|
|
|
},
|
|
|
|
'If the user is logged in, then it doesn\'t signal that the footer link should be shown.'
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
2018-03-14 23:50:09 +00:00
|
|
|
QUnit.test( 'SETTINGS_SHOW', ( assert ) => {
|
2018-05-08 19:48:17 +00:00
|
|
|
assert.expect( 1, 'All assertions are executed.' );
|
2017-02-01 11:09:42 +00:00
|
|
|
|
|
|
|
assert.deepEqual(
|
2018-07-13 15:12:49 +00:00
|
|
|
settings( {}, { type: actionTypes.SETTINGS_SHOW } ),
|
2017-02-01 11:09:42 +00:00
|
|
|
{
|
|
|
|
shouldShow: true,
|
|
|
|
showHelp: false
|
|
|
|
},
|
|
|
|
'It should mark the settings dialog as ready to be shown, with no help.'
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
2018-03-14 23:50:09 +00:00
|
|
|
QUnit.test( 'SETTINGS_HIDE', ( assert ) => {
|
2018-05-08 19:48:17 +00:00
|
|
|
assert.expect( 1, 'All assertions are executed.' );
|
2017-02-01 11:09:42 +00:00
|
|
|
|
|
|
|
assert.deepEqual(
|
2018-07-13 15:12:49 +00:00
|
|
|
settings( {}, { type: actionTypes.SETTINGS_HIDE } ),
|
2017-02-01 11:09:42 +00:00
|
|
|
{
|
|
|
|
shouldShow: false,
|
|
|
|
showHelp: false
|
|
|
|
},
|
|
|
|
'It should mark the settings dialog as ready to be closed, and hide help.'
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
2018-03-14 23:50:09 +00:00
|
|
|
QUnit.test( 'SETTINGS_CHANGE', ( assert ) => {
|
2021-03-31 08:51:54 +00:00
|
|
|
const action = ( oldValue, newValue ) => {
|
2017-02-01 11:09:42 +00:00
|
|
|
return {
|
2018-07-13 15:12:49 +00:00
|
|
|
type: actionTypes.SETTINGS_CHANGE,
|
2021-03-31 08:51:54 +00:00
|
|
|
oldValue,
|
|
|
|
newValue
|
2017-02-01 11:09:42 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
assert.deepEqual(
|
|
|
|
settings( {}, action( false, false ) ),
|
|
|
|
{ shouldShow: false },
|
|
|
|
'It should just hide the settings dialog when enabled state stays the same.'
|
|
|
|
);
|
|
|
|
assert.deepEqual(
|
|
|
|
settings( {}, action( true, true ) ),
|
|
|
|
{ shouldShow: false },
|
|
|
|
'It should just hide the settings dialog when enabled state stays the same.'
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.deepEqual(
|
|
|
|
settings( {}, action( false, true ) ),
|
|
|
|
{
|
|
|
|
shouldShow: false,
|
|
|
|
showHelp: false,
|
|
|
|
shouldShowFooterLink: false
|
|
|
|
},
|
|
|
|
'It should hide the settings dialog and help when we enable.'
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.deepEqual(
|
|
|
|
settings( {}, action( true, false ) ),
|
|
|
|
{
|
|
|
|
shouldShow: true,
|
|
|
|
showHelp: true,
|
|
|
|
shouldShowFooterLink: true
|
|
|
|
},
|
|
|
|
'It should keep the settings showing and show the help when we disable.'
|
|
|
|
);
|
|
|
|
|
|
|
|
} );
|