mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-17 20:41:32 +00:00
ece4670710
In some places, the arrow function seems more natural. This patch approximates the following with manual amendments: find \ -not \( \( -name node_modules -o -name .git -o -name vendor -o -name doc -o -name resources \) -prune \) \ -iname \*.js| xargs -rd\\n sed -ri 's%function\s*(\([^)]*\))%\1 =>%g' Files to focus on were identified with: rg -slg\!/resources/dist/ -g\!/i18n/ -g\!/doc/ 'this|self|arguments|bind|call|apply|new'| xargs -rd\\n git difftool -y Bug: T165036 Change-Id: Ic66b6000b8fc000f9bfde39749f9cfa69924a13c
77 lines
1.3 KiB
JavaScript
77 lines
1.3 KiB
JavaScript
import pageviews from '../../../src/reducers/pageviews';
|
|
|
|
/* eslint-disable camelcase */
|
|
var PAGEVIEW = {
|
|
page_title: 'Bears',
|
|
page_id: 1,
|
|
page_namespace: 0
|
|
}, PAGE = {
|
|
url: 'http://localhost:8888/w/index.php?title=Bird_like_dinosaur',
|
|
title: 'Bird like dinosaur',
|
|
namespaceId: 0,
|
|
id: 673
|
|
};
|
|
|
|
/* eslint-enable camelcase */
|
|
|
|
QUnit.module( 'ext.popups/reducers#pageviews', {
|
|
beforeEach() {
|
|
this.initialState = pageviews( undefined, {
|
|
type: '@@INIT'
|
|
} );
|
|
}
|
|
} );
|
|
|
|
QUnit.test( 'BOOT', function ( assert ) {
|
|
var action = {
|
|
type: 'BOOT',
|
|
page: PAGE
|
|
};
|
|
|
|
assert.deepEqual(
|
|
pageviews( this.initialState, action ),
|
|
{
|
|
page: PAGE,
|
|
pageview: undefined
|
|
},
|
|
'It should set the current page.'
|
|
);
|
|
} );
|
|
|
|
QUnit.test( 'PREVIEW_SEEN', ( assert ) => {
|
|
var action = {
|
|
type: 'PREVIEW_SEEN',
|
|
title: 'Bears',
|
|
pageId: 1,
|
|
namespace: 0
|
|
};
|
|
|
|
assert.expect( 1 );
|
|
|
|
assert.deepEqual(
|
|
pageviews( { page: PAGE }, action ),
|
|
{
|
|
page: PAGE,
|
|
pageview: PAGEVIEW
|
|
},
|
|
'It should set a flag requesting a pageview is recorded.'
|
|
);
|
|
} );
|
|
|
|
QUnit.test( 'PAGEVIEW_LOGGED', ( assert ) => {
|
|
var action = {
|
|
type: 'PAGEVIEW_LOGGED'
|
|
};
|
|
|
|
assert.expect( 1 );
|
|
|
|
assert.deepEqual(
|
|
pageviews( { pageview: PAGEVIEW, page: PAGE }, action ),
|
|
{
|
|
page: PAGE,
|
|
pageview: undefined
|
|
},
|
|
'When complete it should remove the pageview record.'
|
|
);
|
|
} );
|