2017-03-07 00:27:38 +00:00
|
|
|
var statsv = require( '../../../src/reducers/statsv' );
|
|
|
|
|
|
|
|
QUnit.module( 'ext.popups/reducers#eventLogging', {
|
|
|
|
setup: function () {
|
|
|
|
this.initialState = statsv( undefined, {
|
|
|
|
type: '@@INIT'
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
|
|
|
QUnit.test( '@@INIT', function ( assert ) {
|
|
|
|
assert.expect( 1 );
|
|
|
|
|
|
|
|
assert.deepEqual( this.initialState, {} );
|
|
|
|
} );
|
|
|
|
|
|
|
|
QUnit.test( 'FETCH_START', function ( assert ) {
|
|
|
|
var action, state;
|
|
|
|
|
|
|
|
assert.expect( 1 );
|
|
|
|
|
|
|
|
action = {
|
|
|
|
type: 'FETCH_START',
|
|
|
|
timestamp: 123
|
|
|
|
};
|
|
|
|
state = statsv( this.initialState, action );
|
|
|
|
|
|
|
|
assert.deepEqual(
|
|
|
|
state,
|
|
|
|
{
|
|
|
|
fetchStartedAt: 123
|
|
|
|
}
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
2017-03-26 19:33:07 +00:00
|
|
|
QUnit.test( 'FETCH_END', function ( assert ) {
|
2017-03-07 00:27:38 +00:00
|
|
|
var startedAt, endedAt, delay, action, state;
|
|
|
|
|
|
|
|
assert.expect( 1 );
|
|
|
|
|
|
|
|
startedAt = 200;
|
|
|
|
endedAt = 500;
|
|
|
|
action = {
|
2017-03-26 19:33:07 +00:00
|
|
|
type: 'FETCH_END',
|
2017-03-07 00:27:38 +00:00
|
|
|
timestamp: endedAt,
|
|
|
|
};
|
|
|
|
state = statsv( { fetchStartedAt: startedAt }, action );
|
|
|
|
|
|
|
|
assert.deepEqual(
|
|
|
|
state,
|
|
|
|
{
|
|
|
|
fetchStartedAt: startedAt,
|
|
|
|
action: 'timing.PagePreviewsApiResponse',
|
2017-03-26 19:33:07 +00:00
|
|
|
data: endedAt - startedAt
|
2017-03-07 00:27:38 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
|
|
|
QUnit.test( 'FETCH_FAILED', function ( assert ) {
|
|
|
|
var action, state;
|
|
|
|
|
|
|
|
assert.expect( 1 );
|
|
|
|
|
|
|
|
action = {
|
|
|
|
type: 'FETCH_FAILED'
|
|
|
|
};
|
|
|
|
state = statsv( {}, action );
|
|
|
|
|
|
|
|
assert.deepEqual(
|
|
|
|
state,
|
|
|
|
{
|
|
|
|
action: 'counter.PagePreviewsApiFailure',
|
|
|
|
data: 1
|
|
|
|
}
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
|
|
|
QUnit.test( 'LINK_DWELL', function ( assert ) {
|
|
|
|
var timestamp, action, state;
|
|
|
|
|
|
|
|
assert.expect( 1 );
|
|
|
|
|
|
|
|
timestamp = 100;
|
|
|
|
action = {
|
|
|
|
type: 'LINK_DWELL',
|
|
|
|
timestamp: timestamp
|
|
|
|
};
|
|
|
|
state = statsv( {}, action );
|
|
|
|
|
|
|
|
assert.deepEqual(
|
|
|
|
state,
|
|
|
|
{
|
|
|
|
linkDwellStartedAt: timestamp
|
|
|
|
}
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
|
|
|
QUnit.test( 'PREVIEW_SHOW', function ( assert ) {
|
|
|
|
var startedAt, endedAt, action, state;
|
|
|
|
|
|
|
|
assert.expect( 1 );
|
|
|
|
|
|
|
|
startedAt = 100;
|
|
|
|
endedAt = 300;
|
|
|
|
action = {
|
|
|
|
type: 'PREVIEW_SHOW',
|
|
|
|
timestamp: endedAt
|
|
|
|
};
|
|
|
|
state = statsv( { linkDwellStartedAt: startedAt }, action );
|
|
|
|
|
|
|
|
assert.deepEqual(
|
|
|
|
state,
|
|
|
|
{
|
|
|
|
linkDwellStartedAt: startedAt,
|
|
|
|
action: 'timing.PagePreviewsPreviewShow',
|
|
|
|
data: endedAt - startedAt
|
|
|
|
}
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
|
|
|
QUnit.test( 'STATSV_LOGGED', function ( assert ) {
|
|
|
|
var action, state;
|
|
|
|
|
|
|
|
assert.expect( 1 );
|
|
|
|
|
|
|
|
action = {
|
|
|
|
type: 'STATSV_LOGGED'
|
|
|
|
};
|
|
|
|
state = statsv( { data: 123 }, action );
|
|
|
|
|
|
|
|
assert.deepEqual(
|
|
|
|
state,
|
|
|
|
{
|
|
|
|
action: null,
|
|
|
|
data: null
|
|
|
|
}
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
|