mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-30 18:34:40 +00:00
Add tests for rewritten SETTINGS_CHANGE action reducer
The new code that is tested here was introduced in I860a1b3. Bug: T277639 Change-Id: I128e69f8ca0415ff78d68a2fea2c9622c90029e0
This commit is contained in:
parent
e5909e06c5
commit
7f938bb077
|
@ -74,7 +74,7 @@ QUnit.test( 'SETTINGS_HIDE', ( assert ) => {
|
||||||
);
|
);
|
||||||
} );
|
} );
|
||||||
|
|
||||||
QUnit.test( 'SETTINGS_CHANGE', ( assert ) => {
|
QUnit.test( 'SETTINGS_CHANGE with page previews only', ( assert ) => {
|
||||||
const action = ( oldValue, newValue ) => {
|
const action = ( oldValue, newValue ) => {
|
||||||
return {
|
return {
|
||||||
type: actionTypes.SETTINGS_CHANGE,
|
type: actionTypes.SETTINGS_CHANGE,
|
||||||
|
@ -113,5 +113,54 @@ QUnit.test( 'SETTINGS_CHANGE', ( assert ) => {
|
||||||
},
|
},
|
||||||
'It should keep the settings showing and show the help when we disable.'
|
'It should keep the settings showing and show the help when we disable.'
|
||||||
);
|
);
|
||||||
|
} );
|
||||||
|
|
||||||
|
QUnit.test( 'SETTINGS_CHANGE with two preview types', ( assert ) => {
|
||||||
|
[
|
||||||
|
[
|
||||||
|
'All are disabled but nothing changed',
|
||||||
|
false, false, false, false,
|
||||||
|
{ shouldShow: false }
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'All are enabled but nothing changed',
|
||||||
|
true, true, true, true,
|
||||||
|
{ shouldShow: false }
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'One is enabled but nothing changed',
|
||||||
|
false, false, true, true,
|
||||||
|
{ shouldShow: false }
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'Only one got disabled',
|
||||||
|
true, true, true, false,
|
||||||
|
{ shouldShow: true, showHelp: true, shouldShowFooterLink: true }
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'Both got disabled',
|
||||||
|
true, false, true, false,
|
||||||
|
{ shouldShow: true, showHelp: true, shouldShowFooterLink: true }
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'Only one got enabled',
|
||||||
|
false, false, false, true,
|
||||||
|
{ shouldShow: false, showHelp: false, shouldShowFooterLink: true }
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'Both got enabled',
|
||||||
|
false, true, false, true,
|
||||||
|
{ shouldShow: false, showHelp: false, shouldShowFooterLink: false }
|
||||||
|
]
|
||||||
|
].forEach( ( testCase, index ) => {
|
||||||
|
assert.deepEqual(
|
||||||
|
settings( {}, {
|
||||||
|
type: actionTypes.SETTINGS_CHANGE,
|
||||||
|
oldValue: { page: testCase[ 1 ], reference: testCase[ 3 ] },
|
||||||
|
newValue: { page: testCase[ 2 ], reference: testCase[ 4 ] }
|
||||||
|
} ),
|
||||||
|
testCase[ 5 ],
|
||||||
|
testCase[ 0 ] || 'Test case #' + index
|
||||||
|
);
|
||||||
|
} );
|
||||||
} );
|
} );
|
||||||
|
|
Loading…
Reference in a new issue