2018-02-08 22:11:44 +00:00
|
|
|
import pageviews from '../../../src/reducers/pageviews';
|
|
|
|
|
2018-02-15 20:15:23 +00:00
|
|
|
/* eslint-disable camelcase */
|
2018-02-21 18:28:56 +00:00
|
|
|
var 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', {
|
|
|
|
beforeEach: function () {
|
|
|
|
this.initialState = pageviews( undefined, {
|
|
|
|
type: '@@INIT'
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
2018-02-15 20:15:23 +00:00
|
|
|
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.'
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
2018-02-08 22:11:44 +00:00
|
|
|
QUnit.test( 'PREVIEW_SEEN', function ( assert ) {
|
|
|
|
var action = {
|
|
|
|
type: 'PREVIEW_SEEN',
|
|
|
|
title: 'Bears',
|
2018-02-15 20:15:23 +00:00
|
|
|
pageId: 1,
|
2018-02-08 22:11:44 +00:00
|
|
|
namespace: 0
|
|
|
|
};
|
|
|
|
|
|
|
|
assert.expect( 1 );
|
|
|
|
|
|
|
|
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
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
|
|
|
QUnit.test( 'PAGEVIEW_LOGGED', function ( assert ) {
|
|
|
|
var action = {
|
|
|
|
type: 'PAGEVIEW_LOGGED'
|
|
|
|
};
|
|
|
|
|
|
|
|
assert.expect( 1 );
|
|
|
|
|
|
|
|
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.'
|
|
|
|
);
|
|
|
|
} );
|