mediawiki-extensions-Popups/tests/node-qunit/reducers/pageviews.test.js
jdlrobson 535149c16c Upgrade schema and log the required fields
This change updates the schema and begins to log
additional information such as source_namespace, id
and title. This information is provided inside the
boot action.

Additional changes:
* Allow camel case in bundle artifact

Bug: T184793
Bug: T186728
Change-Id: I425ffecc018bef2958d0dfe957a40a065e3e6c56
2018-02-26 10:25:30 -08:00

77 lines
1.4 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: function () {
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', function ( 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', function ( 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.'
);
} );