2016-11-10 18:02:29 +00:00
|
|
|
( function ( mw ) {
|
|
|
|
|
|
|
|
QUnit.module( 'ext.popups/reducers' );
|
|
|
|
|
|
|
|
QUnit.test( '#rootReducer', function ( assert ) {
|
|
|
|
var state = mw.popups.reducers.rootReducer( undefined, { type: '@@INIT' } );
|
|
|
|
|
|
|
|
assert.expect( 1 );
|
|
|
|
|
|
|
|
assert.deepEqual(
|
|
|
|
state,
|
|
|
|
{
|
|
|
|
preview: {
|
2016-11-14 19:37:11 +00:00
|
|
|
enabled: undefined,
|
|
|
|
sessionToken: undefined,
|
|
|
|
pageToken: undefined,
|
|
|
|
linkInteractionToken: undefined,
|
2016-11-10 18:02:29 +00:00
|
|
|
activeLink: undefined,
|
|
|
|
interactionStarted: undefined,
|
|
|
|
isDelayingFetch: false,
|
2016-11-14 19:37:11 +00:00
|
|
|
isFetching: false
|
2016-11-10 18:02:29 +00:00
|
|
|
},
|
|
|
|
renderer: {
|
2016-11-16 16:16:43 +00:00
|
|
|
isAnimating: false,
|
2016-11-10 18:02:29 +00:00
|
|
|
isInteractive: false,
|
|
|
|
showSettings: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'It should initialize the state by default'
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
2016-11-16 16:16:43 +00:00
|
|
|
QUnit.test( '#preview', function ( assert ) {
|
2016-11-14 19:37:11 +00:00
|
|
|
var state = mw.popups.reducers.preview( undefined, { type: '@@INIT' } ),
|
|
|
|
action = {
|
2016-11-10 18:02:29 +00:00
|
|
|
type: 'BOOT',
|
2016-11-14 19:37:11 +00:00
|
|
|
isUserInCondition: true,
|
|
|
|
sessionToken: '0123456789',
|
|
|
|
pageToken: '9876543210'
|
|
|
|
};
|
2016-11-10 18:02:29 +00:00
|
|
|
|
2016-11-16 16:16:43 +00:00
|
|
|
assert.expect( 1 );
|
|
|
|
|
2016-11-14 19:37:11 +00:00
|
|
|
assert.deepEqual(
|
|
|
|
mw.popups.reducers.preview( state, action ),
|
|
|
|
{
|
|
|
|
enabled: true,
|
|
|
|
sessionToken: '0123456789',
|
|
|
|
pageToken: '9876543210',
|
|
|
|
isDelayingFetch: false,
|
|
|
|
isFetching: false
|
2016-11-16 16:16:43 +00:00
|
|
|
},
|
|
|
|
'It should set enabled and the session tokens on the BOOT action'
|
2016-11-10 18:02:29 +00:00
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
|
|
|
QUnit.test( '#renderer', function ( assert ) {
|
|
|
|
assert.expect( 1 );
|
|
|
|
|
|
|
|
assert.deepEqual(
|
|
|
|
mw.popups.reducers.renderer( {}, { type: 'PREVIEW_ANIMATING' } ),
|
2016-11-16 16:16:43 +00:00
|
|
|
{
|
|
|
|
isAnimating: true,
|
|
|
|
isInteractive: false,
|
|
|
|
showSettings: false
|
|
|
|
},
|
|
|
|
'It should set isAnimating to true on the PREVIEW_ANIMATING action'
|
2016-11-10 18:02:29 +00:00
|
|
|
);
|
|
|
|
} );
|
|
|
|
}( mediaWiki ) );
|
|
|
|
|