2018-02-08 22:11:44 +00:00
|
|
|
import pageviews from '../../../src/reducers/pageviews';
|
2018-07-13 15:12:49 +00:00
|
|
|
import actionTypes from '../../../src/actionTypes';
|
2018-02-08 22:11:44 +00:00
|
|
|
|
2018-02-15 20:15:23 +00:00
|
|
|
/* eslint-disable camelcase */
|
2018-03-19 19:39:41 +00:00
|
|
|
const PAGEVIEW = {
|
2018-02-15 20:15:23 +00:00
|
|
|
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 */
|
2018-02-08 22:11:44 +00:00
|
|
|
|
|
|
|
QUnit.module( 'ext.popups/reducers#pageviews', {
|
2018-03-14 22:04:59 +00:00
|
|
|
beforeEach() {
|
2018-02-08 22:11:44 +00:00
|
|
|
this.initialState = pageviews( undefined, {
|
|
|
|
type: '@@INIT'
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
2018-02-15 20:15:23 +00:00
|
|
|
QUnit.test( 'BOOT', function ( assert ) {
|
2018-03-19 19:39:41 +00:00
|
|
|
const action = {
|
2018-07-13 15:12:49 +00:00
|
|
|
type: actionTypes.BOOT,
|
2018-02-15 20:15:23 +00:00
|
|
|
page: PAGE
|
|
|
|
};
|
|
|
|
|
|
|
|
assert.deepEqual(
|
|
|
|
pageviews( this.initialState, action ),
|
|
|
|
{
|
|
|
|
page: PAGE,
|
|
|
|
pageview: undefined
|
|
|
|
},
|
|
|
|
'It should set the current page.'
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
2018-03-14 23:50:09 +00:00
|
|
|
QUnit.test( 'PREVIEW_SEEN', ( assert ) => {
|
2018-03-19 19:39:41 +00:00
|
|
|
const action = {
|
2018-07-13 15:12:49 +00:00
|
|
|
type: actionTypes.PREVIEW_SEEN,
|
2018-02-08 22:11:44 +00:00
|
|
|
title: 'Bears',
|
2018-02-15 20:15:23 +00:00
|
|
|
pageId: 1,
|
2018-02-08 22:11:44 +00:00
|
|
|
namespace: 0
|
|
|
|
};
|
|
|
|
|
2018-05-08 19:48:17 +00:00
|
|
|
assert.expect( 1, 'All assertions are executed.' );
|
2018-02-08 22:11:44 +00:00
|
|
|
|
|
|
|
assert.deepEqual(
|
2018-02-15 20:15:23 +00:00
|
|
|
pageviews( { page: PAGE }, action ),
|
2018-02-08 22:11:44 +00:00
|
|
|
{
|
2018-02-15 20:15:23 +00:00
|
|
|
page: PAGE,
|
2018-02-21 18:28:56 +00:00
|
|
|
pageview: PAGEVIEW
|
2018-02-08 22:11:44 +00:00
|
|
|
},
|
2018-02-21 18:28:56 +00:00
|
|
|
'It should set a flag requesting a pageview is recorded.'
|
2018-02-08 22:11:44 +00:00
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
2018-03-14 23:50:09 +00:00
|
|
|
QUnit.test( 'PAGEVIEW_LOGGED', ( assert ) => {
|
2018-03-19 19:39:41 +00:00
|
|
|
const action = {
|
2018-07-13 15:12:49 +00:00
|
|
|
type: actionTypes.PAGEVIEW_LOGGED
|
2018-02-08 22:11:44 +00:00
|
|
|
};
|
|
|
|
|
2018-05-08 19:48:17 +00:00
|
|
|
assert.expect( 1, 'All assertions are executed.' );
|
2018-02-08 22:11:44 +00:00
|
|
|
|
|
|
|
assert.deepEqual(
|
2018-02-15 20:15:23 +00:00
|
|
|
pageviews( { pageview: PAGEVIEW, page: PAGE }, action ),
|
2018-02-08 22:11:44 +00:00
|
|
|
{
|
2018-02-15 20:15:23 +00:00
|
|
|
page: PAGE,
|
2018-02-08 22:11:44 +00:00
|
|
|
pageview: undefined
|
|
|
|
},
|
|
|
|
'When complete it should remove the pageview record.'
|
|
|
|
);
|
|
|
|
} );
|