mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-27 17:00:37 +00:00
Hygiene: use actionsTest consts instead of hardcoded states
The unit tests should use defined action types instead of hardcoding each state. Change-Id: I6769ba057e93239e1c720c3bfa050c618ea63978
This commit is contained in:
parent
c823a0e6cb
commit
4684b39841
|
@ -1,6 +1,7 @@
|
|||
import { createStubUser, createStubTitle } from './stubs';
|
||||
import * as actions from '../../src/actions';
|
||||
import * as WaitModule from '../../src/wait';
|
||||
import actionTypes from '../../src/actionTypes';
|
||||
|
||||
const mw = mediaWiki,
|
||||
REFERRER = 'https://en.wikipedia.org/wiki/Kitten';
|
||||
|
@ -41,7 +42,7 @@ QUnit.test( '#boot', ( assert ) => {
|
|||
assert.deepEqual(
|
||||
action,
|
||||
{
|
||||
type: 'BOOT',
|
||||
type: actionTypes.BOOT,
|
||||
isEnabled: false,
|
||||
isNavPopupsEnabled: true,
|
||||
sessionToken: '0123456789',
|
||||
|
@ -123,7 +124,7 @@ QUnit.test( '#linkDwell', function ( assert ) {
|
|||
|
||||
assert.propEqual(
|
||||
dispatch.getCall( 0 ).args[ 0 ], {
|
||||
type: 'LINK_DWELL',
|
||||
type: actionTypes.LINK_DWELL,
|
||||
el: this.el,
|
||||
event,
|
||||
token: '9876543210',
|
||||
|
@ -297,7 +298,7 @@ QUnit.test( 'it should fetch data from the gateway immediately', function ( asse
|
|||
assert.propEqual(
|
||||
this.dispatch.getCall( 0 ).args[ 0 ],
|
||||
{
|
||||
type: 'FETCH_START',
|
||||
type: actionTypes.FETCH_START,
|
||||
el: this.el,
|
||||
title: 'Foo',
|
||||
namespaceId: 1,
|
||||
|
@ -320,7 +321,7 @@ QUnit.test( 'it should dispatch the FETCH_END action when the API request ends',
|
|||
assert.deepEqual(
|
||||
this.dispatch.getCall( 1 ).args[ 0 ],
|
||||
{
|
||||
type: 'FETCH_END',
|
||||
type: actionTypes.FETCH_END,
|
||||
el: this.el,
|
||||
timestamp: 115
|
||||
},
|
||||
|
@ -346,7 +347,7 @@ QUnit.test( 'it should delay dispatching the FETCH_COMPLETE action', function (
|
|||
assert.deepEqual(
|
||||
this.dispatch.getCall( 2 ).args[ 0 ],
|
||||
{
|
||||
type: 'FETCH_COMPLETE',
|
||||
type: actionTypes.FETCH_COMPLETE,
|
||||
el: this.el,
|
||||
result,
|
||||
token: this.token
|
||||
|
@ -373,7 +374,7 @@ QUnit.test( 'it should dispatch the FETCH_FAILED action when the request fails',
|
|||
assert.deepEqual(
|
||||
this.dispatch.getCall( 1 ).args[ 0 ],
|
||||
{
|
||||
type: 'FETCH_FAILED',
|
||||
type: actionTypes.FETCH_FAILED,
|
||||
el: this.el
|
||||
},
|
||||
'The dispatcher was called with the correct arguments.'
|
||||
|
@ -396,7 +397,7 @@ QUnit.test( 'it should dispatch the FETCH_FAILED action when the request fails e
|
|||
assert.deepEqual(
|
||||
this.dispatch.getCall( 1 ).args[ 0 ],
|
||||
{
|
||||
type: 'FETCH_FAILED',
|
||||
type: actionTypes.FETCH_FAILED,
|
||||
el: this.el
|
||||
},
|
||||
'The dispatcher was called with the correct arguments.'
|
||||
|
@ -424,7 +425,7 @@ QUnit.test( 'it should dispatch the FETCH_ABORTED action when the request is abo
|
|||
assert.deepEqual(
|
||||
this.dispatch.getCall( 1 ).args[ 0 ],
|
||||
{
|
||||
type: 'FETCH_ABORTED',
|
||||
type: actionTypes.FETCH_ABORTED,
|
||||
el: this.el
|
||||
},
|
||||
'The dispatcher was called with the correct arguments.'
|
||||
|
@ -458,7 +459,7 @@ QUnit.test( 'it should dispatch start and end actions', function ( assert ) {
|
|||
|
||||
assert.ok(
|
||||
dispatch.calledWith( {
|
||||
type: 'ABANDON_START',
|
||||
type: actionTypes.ABANDON_START,
|
||||
timestamp: mw.now(),
|
||||
token
|
||||
} ),
|
||||
|
@ -475,7 +476,7 @@ QUnit.test( 'it should dispatch start and end actions', function ( assert ) {
|
|||
return abandoned.then( () => {
|
||||
assert.ok(
|
||||
dispatch.calledWith( {
|
||||
type: 'ABANDON_END',
|
||||
type: actionTypes.ABANDON_END,
|
||||
token
|
||||
} ),
|
||||
'ABANDON_* share the same token.'
|
||||
|
@ -520,7 +521,7 @@ QUnit.test( 'it should dispatch an action with previous and current enabled stat
|
|||
);
|
||||
assert.ok(
|
||||
dispatch.calledWith( {
|
||||
type: 'SETTINGS_CHANGE',
|
||||
type: actionTypes.SETTINGS_CHANGE,
|
||||
wasEnabled: false,
|
||||
enabled: true
|
||||
} ),
|
||||
|
@ -554,7 +555,7 @@ QUnit.test( 'it should dispatch the PREVIEW_SHOW action and log a pageview', fun
|
|||
|
||||
assert.ok(
|
||||
dispatch.calledWith( {
|
||||
type: 'PREVIEW_SHOW',
|
||||
type: actionTypes.PREVIEW_SHOW,
|
||||
token,
|
||||
timestamp: mw.now()
|
||||
} ),
|
||||
|
@ -573,7 +574,7 @@ QUnit.test( 'it should dispatch the PREVIEW_SHOW action and log a pageview', fun
|
|||
);
|
||||
assert.ok(
|
||||
dispatch.calledWith( {
|
||||
type: 'PREVIEW_SEEN',
|
||||
type: actionTypes.PREVIEW_SEEN,
|
||||
namespace: 0,
|
||||
pageId: 42,
|
||||
title: 'A'
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import * as counts from '../../../src/counts';
|
||||
import { createModel } from '../../../src/preview/model';
|
||||
import eventLogging from '../../../src/reducers/eventLogging';
|
||||
import actionTypes from '../../../src/actionTypes';
|
||||
|
||||
QUnit.module( 'ext.popups/reducers#eventLogging', {
|
||||
beforeEach() {
|
||||
|
@ -25,7 +26,7 @@ QUnit.test( '@@INIT', function ( assert ) {
|
|||
|
||||
QUnit.test( 'BOOT', function ( assert ) {
|
||||
const action = {
|
||||
type: 'BOOT',
|
||||
type: actionTypes.BOOT,
|
||||
isEnabled: true,
|
||||
isNavPopupsEnabled: false,
|
||||
sessionToken: '0123456789',
|
||||
|
@ -98,7 +99,7 @@ QUnit.test( 'EVENT_LOGGED', ( assert ) => {
|
|||
};
|
||||
|
||||
let action = {
|
||||
type: 'EVENT_LOGGED',
|
||||
type: actionTypes.EVENT_LOGGED,
|
||||
event: {}
|
||||
};
|
||||
|
||||
|
@ -118,7 +119,7 @@ QUnit.test( 'EVENT_LOGGED', ( assert ) => {
|
|||
};
|
||||
|
||||
action = {
|
||||
type: 'EVENT_LOGGED',
|
||||
type: actionTypes.EVENT_LOGGED,
|
||||
event: state.event
|
||||
};
|
||||
|
||||
|
@ -152,7 +153,7 @@ QUnit.test( 'PREVIEW_SHOW', ( assert ) => {
|
|||
};
|
||||
|
||||
state = eventLogging( state, {
|
||||
type: 'PREVIEW_SHOW',
|
||||
type: actionTypes.PREVIEW_SHOW,
|
||||
token
|
||||
} );
|
||||
|
||||
|
@ -183,7 +184,7 @@ QUnit.test( 'LINK_DWELL starts an interaction', function ( assert ) {
|
|||
};
|
||||
|
||||
const action = {
|
||||
type: 'LINK_DWELL',
|
||||
type: actionTypes.LINK_DWELL,
|
||||
el: this.link,
|
||||
title: 'Foo',
|
||||
namespaceId: 1,
|
||||
|
@ -217,7 +218,7 @@ QUnit.test( 'LINK_DWELL doesn\'t start a new interaction under certain condition
|
|||
};
|
||||
|
||||
const action = {
|
||||
type: 'LINK_DWELL',
|
||||
type: actionTypes.LINK_DWELL,
|
||||
el: this.link,
|
||||
title: 'Foo',
|
||||
namespaceId: 1,
|
||||
|
@ -254,7 +255,7 @@ QUnit.test( 'LINK_DWELL should enqueue a "dismissed" or "dwelledButAbandoned" ev
|
|||
// Read: The user dwells on link A, abandons it, and dwells on link B fewer
|
||||
// than 300 ms after (before the ABANDON_END action is reduced).
|
||||
let state = eventLogging( undefined, {
|
||||
type: 'LINK_DWELL',
|
||||
type: actionTypes.LINK_DWELL,
|
||||
el: this.link,
|
||||
title: 'Foo',
|
||||
namespaceId: 1,
|
||||
|
@ -263,12 +264,12 @@ QUnit.test( 'LINK_DWELL should enqueue a "dismissed" or "dwelledButAbandoned" ev
|
|||
} );
|
||||
|
||||
state = eventLogging( state, {
|
||||
type: 'ABANDON_START',
|
||||
type: actionTypes.ABANDON_START,
|
||||
timestamp: now + 250
|
||||
} );
|
||||
|
||||
state = eventLogging( state, {
|
||||
type: 'LINK_DWELL',
|
||||
type: actionTypes.LINK_DWELL,
|
||||
el: $( '<a>' ),
|
||||
title: 'Bar',
|
||||
namespaceId: 1,
|
||||
|
@ -291,7 +292,7 @@ QUnit.test( 'LINK_DWELL should enqueue a "dismissed" or "dwelledButAbandoned" ev
|
|||
// ---
|
||||
|
||||
state = eventLogging( undefined, {
|
||||
type: 'LINK_DWELL',
|
||||
type: actionTypes.LINK_DWELL,
|
||||
el: this.link,
|
||||
title: 'Foo',
|
||||
namespaceId: 1,
|
||||
|
@ -300,12 +301,12 @@ QUnit.test( 'LINK_DWELL should enqueue a "dismissed" or "dwelledButAbandoned" ev
|
|||
} );
|
||||
|
||||
state = eventLogging( state, {
|
||||
type: 'LINK_CLICK',
|
||||
type: actionTypes.LINK_CLICK,
|
||||
el: this.link
|
||||
} );
|
||||
|
||||
state = eventLogging( state, {
|
||||
type: 'LINK_DWELL',
|
||||
type: actionTypes.LINK_DWELL,
|
||||
el: $( '<a>' ),
|
||||
title: 'Bar',
|
||||
namespaceId: 1,
|
||||
|
@ -329,7 +330,7 @@ QUnit.test( 'LINK_CLICK should enqueue an "opened" event', function ( assert ) {
|
|||
};
|
||||
|
||||
const expectedState = state = eventLogging( state, {
|
||||
type: 'LINK_DWELL',
|
||||
type: actionTypes.LINK_DWELL,
|
||||
el: this.link,
|
||||
title: 'Foo',
|
||||
namespaceId: 1,
|
||||
|
@ -338,7 +339,7 @@ QUnit.test( 'LINK_CLICK should enqueue an "opened" event', function ( assert ) {
|
|||
} );
|
||||
|
||||
state = eventLogging( state, {
|
||||
type: 'LINK_CLICK',
|
||||
type: actionTypes.LINK_CLICK,
|
||||
el: this.link,
|
||||
timestamp: now + 250
|
||||
} );
|
||||
|
@ -373,7 +374,7 @@ QUnit.test( 'PREVIEW_SHOW should update the perceived wait time of the interacti
|
|||
};
|
||||
|
||||
state = eventLogging( state, {
|
||||
type: 'LINK_DWELL',
|
||||
type: actionTypes.LINK_DWELL,
|
||||
el: this.link,
|
||||
title: 'Foo',
|
||||
namespaceId: 1,
|
||||
|
@ -382,7 +383,7 @@ QUnit.test( 'PREVIEW_SHOW should update the perceived wait time of the interacti
|
|||
} );
|
||||
|
||||
state = eventLogging( state, {
|
||||
type: 'PREVIEW_SHOW',
|
||||
type: actionTypes.PREVIEW_SHOW,
|
||||
token,
|
||||
timestamp: now + 500
|
||||
} );
|
||||
|
@ -412,7 +413,7 @@ QUnit.test( 'LINK_CLICK should include perceivedWait if the preview has been sho
|
|||
};
|
||||
|
||||
state = eventLogging( state, {
|
||||
type: 'LINK_DWELL',
|
||||
type: actionTypes.LINK_DWELL,
|
||||
el: this.link,
|
||||
title: 'Foo',
|
||||
namespaceId: 1,
|
||||
|
@ -421,13 +422,13 @@ QUnit.test( 'LINK_CLICK should include perceivedWait if the preview has been sho
|
|||
} );
|
||||
|
||||
state = eventLogging( state, {
|
||||
type: 'PREVIEW_SHOW',
|
||||
type: actionTypes.PREVIEW_SHOW,
|
||||
token,
|
||||
timestamp: now + 750
|
||||
} );
|
||||
|
||||
state = eventLogging( state, {
|
||||
type: 'LINK_CLICK',
|
||||
type: actionTypes.LINK_CLICK,
|
||||
el: this.link,
|
||||
timestamp: now + 1050
|
||||
} );
|
||||
|
@ -465,7 +466,7 @@ QUnit.test( 'FETCH_COMPLETE', ( assert ) => {
|
|||
{}
|
||||
);
|
||||
let state = eventLogging( initialState, {
|
||||
type: 'FETCH_COMPLETE',
|
||||
type: actionTypes.FETCH_COMPLETE,
|
||||
result: model,
|
||||
token
|
||||
} );
|
||||
|
@ -478,7 +479,7 @@ QUnit.test( 'FETCH_COMPLETE', ( assert ) => {
|
|||
|
||||
// ---
|
||||
state = eventLogging( initialState, {
|
||||
type: 'FETCH_COMPLETE',
|
||||
type: actionTypes.FETCH_COMPLETE,
|
||||
result: model,
|
||||
token: 'banana'
|
||||
} );
|
||||
|
@ -493,7 +494,7 @@ QUnit.test( 'FETCH_COMPLETE', ( assert ) => {
|
|||
delete initialState.interaction;
|
||||
|
||||
state = eventLogging( initialState, {
|
||||
type: 'FETCH_COMPLETE',
|
||||
type: actionTypes.FETCH_COMPLETE,
|
||||
result: model,
|
||||
token: '0123456789'
|
||||
} );
|
||||
|
@ -511,7 +512,7 @@ QUnit.test( 'ABANDON_START', function ( assert ) {
|
|||
};
|
||||
|
||||
state = eventLogging( state, {
|
||||
type: 'ABANDON_START',
|
||||
type: actionTypes.ABANDON_START,
|
||||
timestamp: Date.now()
|
||||
} );
|
||||
|
||||
|
@ -523,7 +524,7 @@ QUnit.test( 'ABANDON_START', function ( assert ) {
|
|||
|
||||
QUnit.test( 'ABANDON_END', function ( assert ) {
|
||||
let action = {
|
||||
type: 'LINK_DWELL',
|
||||
type: actionTypes.LINK_DWELL,
|
||||
el: this.link,
|
||||
title: 'Foo',
|
||||
namespaceId: 1,
|
||||
|
@ -534,7 +535,7 @@ QUnit.test( 'ABANDON_END', function ( assert ) {
|
|||
const state = eventLogging( state, action );
|
||||
|
||||
action = {
|
||||
type: 'ABANDON_END',
|
||||
type: actionTypes.ABANDON_END,
|
||||
token: '1234567890'
|
||||
};
|
||||
|
||||
|
@ -561,7 +562,7 @@ QUnit.test( 'PREVIEW_DWELL', ( assert ) => {
|
|||
};
|
||||
|
||||
state = eventLogging( state, {
|
||||
type: 'PREVIEW_DWELL'
|
||||
type: actionTypes.PREVIEW_DWELL
|
||||
} );
|
||||
|
||||
assert.ok(
|
||||
|
@ -577,7 +578,7 @@ QUnit.test( 'SETTINGS_SHOW should enqueue a "tapped settings cog" event', functi
|
|||
token = '0123456789';
|
||||
|
||||
let state = eventLogging( initialState, {
|
||||
type: 'SETTINGS_SHOW'
|
||||
type: actionTypes.SETTINGS_SHOW
|
||||
} );
|
||||
|
||||
// Note well that this is a valid event. The "tapped settings cog" event is
|
||||
|
@ -596,7 +597,7 @@ QUnit.test( 'SETTINGS_SHOW should enqueue a "tapped settings cog" event', functi
|
|||
// ---
|
||||
|
||||
state = eventLogging( initialState, {
|
||||
type: 'LINK_DWELL',
|
||||
type: actionTypes.LINK_DWELL,
|
||||
el: this.link,
|
||||
title: 'Foo',
|
||||
namespaceId: 1,
|
||||
|
@ -605,7 +606,7 @@ QUnit.test( 'SETTINGS_SHOW should enqueue a "tapped settings cog" event', functi
|
|||
} );
|
||||
|
||||
state = eventLogging( state, {
|
||||
type: 'SETTINGS_SHOW'
|
||||
type: actionTypes.SETTINGS_SHOW
|
||||
} );
|
||||
|
||||
assert.deepEqual(
|
||||
|
@ -622,7 +623,7 @@ QUnit.test( 'SETTINGS_SHOW should enqueue a "tapped settings cog" event', functi
|
|||
|
||||
QUnit.test( 'SETTINGS_CHANGE should enqueue disabled event', ( assert ) => {
|
||||
let state = eventLogging( undefined, {
|
||||
type: 'SETTINGS_CHANGE',
|
||||
type: actionTypes.SETTINGS_CHANGE,
|
||||
wasEnabled: false,
|
||||
enabled: false
|
||||
} );
|
||||
|
@ -634,7 +635,7 @@ QUnit.test( 'SETTINGS_CHANGE should enqueue disabled event', ( assert ) => {
|
|||
);
|
||||
|
||||
state = eventLogging( state, {
|
||||
type: 'SETTINGS_CHANGE',
|
||||
type: actionTypes.SETTINGS_CHANGE,
|
||||
wasEnabled: true,
|
||||
enabled: false
|
||||
} );
|
||||
|
@ -650,7 +651,7 @@ QUnit.test( 'SETTINGS_CHANGE should enqueue disabled event', ( assert ) => {
|
|||
|
||||
delete state.event;
|
||||
state = eventLogging( state, {
|
||||
type: 'SETTINGS_CHANGE',
|
||||
type: actionTypes.SETTINGS_CHANGE,
|
||||
wasEnabled: false,
|
||||
enabled: true
|
||||
} );
|
||||
|
@ -667,7 +668,7 @@ QUnit.test( 'ABANDON_END should enqueue an event', function ( assert ) {
|
|||
now = Date.now();
|
||||
|
||||
const dwelledState = eventLogging( undefined, {
|
||||
type: 'LINK_DWELL',
|
||||
type: actionTypes.LINK_DWELL,
|
||||
el: this.link,
|
||||
title: 'Foo',
|
||||
namespaceId: 1,
|
||||
|
@ -676,13 +677,13 @@ QUnit.test( 'ABANDON_END should enqueue an event', function ( assert ) {
|
|||
} );
|
||||
|
||||
let state = eventLogging( dwelledState, {
|
||||
type: 'ABANDON_START',
|
||||
type: actionTypes.ABANDON_START,
|
||||
token,
|
||||
timestamp: now + 500
|
||||
} );
|
||||
|
||||
state = eventLogging( state, {
|
||||
type: 'ABANDON_END',
|
||||
type: actionTypes.ABANDON_END,
|
||||
token
|
||||
} );
|
||||
|
||||
|
@ -707,19 +708,19 @@ QUnit.test( 'ABANDON_END should enqueue an event', function ( assert ) {
|
|||
// ---
|
||||
|
||||
state = eventLogging( dwelledState, {
|
||||
type: 'PREVIEW_SHOW',
|
||||
type: actionTypes.PREVIEW_SHOW,
|
||||
token,
|
||||
timestamp: now + 700
|
||||
} );
|
||||
|
||||
state = eventLogging( state, {
|
||||
type: 'ABANDON_START',
|
||||
type: actionTypes.ABANDON_START,
|
||||
token,
|
||||
timestamp: now + 850
|
||||
} );
|
||||
|
||||
state = eventLogging( state, {
|
||||
type: 'ABANDON_END',
|
||||
type: actionTypes.ABANDON_END,
|
||||
token
|
||||
} );
|
||||
|
||||
|
@ -746,7 +747,7 @@ QUnit.test( 'ABANDON_END doesn\'t enqueue an event under certain conditions', fu
|
|||
now = Date.now();
|
||||
|
||||
const dwelledState = eventLogging( undefined, {
|
||||
type: 'LINK_DWELL',
|
||||
type: actionTypes.LINK_DWELL,
|
||||
el: this.link,
|
||||
title: 'Foo',
|
||||
namespaceId: 1,
|
||||
|
@ -755,7 +756,7 @@ QUnit.test( 'ABANDON_END doesn\'t enqueue an event under certain conditions', fu
|
|||
} );
|
||||
|
||||
let state = eventLogging( dwelledState, {
|
||||
type: 'ABANDON_END',
|
||||
type: actionTypes.ABANDON_END,
|
||||
token: '1234567890'
|
||||
} );
|
||||
|
||||
|
@ -768,7 +769,7 @@ QUnit.test( 'ABANDON_END doesn\'t enqueue an event under certain conditions', fu
|
|||
// ---
|
||||
|
||||
state = eventLogging( dwelledState, {
|
||||
type: 'ABANDON_END',
|
||||
type: actionTypes.ABANDON_END,
|
||||
token
|
||||
} );
|
||||
|
||||
|
@ -781,23 +782,23 @@ QUnit.test( 'ABANDON_END doesn\'t enqueue an event under certain conditions', fu
|
|||
// ---
|
||||
|
||||
state = eventLogging( dwelledState, {
|
||||
type: 'LINK_CLICK',
|
||||
type: actionTypes.LINK_CLICK,
|
||||
timestamp: now + 500
|
||||
} );
|
||||
|
||||
state = eventLogging( state, {
|
||||
type: 'EVENT_LOGGED',
|
||||
type: actionTypes.EVENT_LOGGED,
|
||||
event: {}
|
||||
} );
|
||||
|
||||
state = eventLogging( state, {
|
||||
type: 'ABANDON_START',
|
||||
type: actionTypes.ABANDON_START,
|
||||
token,
|
||||
timestamp: now + 700
|
||||
} );
|
||||
|
||||
state = eventLogging( state, {
|
||||
type: 'ABANDON_END',
|
||||
type: actionTypes.ABANDON_END,
|
||||
token,
|
||||
timestamp: now + 1000 // ABANDON_END_DELAY is 300 ms.
|
||||
} );
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import pageviews from '../../../src/reducers/pageviews';
|
||||
import actionTypes from '../../../src/actionTypes';
|
||||
|
||||
/* eslint-disable camelcase */
|
||||
const PAGEVIEW = {
|
||||
|
@ -24,7 +25,7 @@ QUnit.module( 'ext.popups/reducers#pageviews', {
|
|||
|
||||
QUnit.test( 'BOOT', function ( assert ) {
|
||||
const action = {
|
||||
type: 'BOOT',
|
||||
type: actionTypes.BOOT,
|
||||
page: PAGE
|
||||
};
|
||||
|
||||
|
@ -40,7 +41,7 @@ QUnit.test( 'BOOT', function ( assert ) {
|
|||
|
||||
QUnit.test( 'PREVIEW_SEEN', ( assert ) => {
|
||||
const action = {
|
||||
type: 'PREVIEW_SEEN',
|
||||
type: actionTypes.PREVIEW_SEEN,
|
||||
title: 'Bears',
|
||||
pageId: 1,
|
||||
namespace: 0
|
||||
|
@ -60,7 +61,7 @@ QUnit.test( 'PREVIEW_SEEN', ( assert ) => {
|
|||
|
||||
QUnit.test( 'PAGEVIEW_LOGGED', ( assert ) => {
|
||||
const action = {
|
||||
type: 'PAGEVIEW_LOGGED'
|
||||
type: actionTypes.PAGEVIEW_LOGGED
|
||||
};
|
||||
|
||||
assert.expect( 1, 'All assertions are executed.' );
|
||||
|
|
|
@ -29,7 +29,7 @@ QUnit.test( '@@INIT', ( assert ) => {
|
|||
|
||||
QUnit.test( 'BOOT', ( assert ) => {
|
||||
const action = {
|
||||
type: 'BOOT',
|
||||
type: actionTypes.BOOT,
|
||||
isEnabled: true
|
||||
};
|
||||
|
||||
|
@ -46,7 +46,7 @@ QUnit.test( 'BOOT', ( assert ) => {
|
|||
|
||||
QUnit.test( 'SETTINGS_CHANGE', ( assert ) => {
|
||||
const action = {
|
||||
type: 'SETTINGS_CHANGE',
|
||||
type: actionTypes.SETTINGS_CHANGE,
|
||||
enabled: true
|
||||
};
|
||||
|
||||
|
@ -64,7 +64,7 @@ QUnit.test( 'SETTINGS_CHANGE', ( assert ) => {
|
|||
QUnit.test( 'LINK_DWELL initializes the state for a new link', function ( assert ) {
|
||||
const promise = $.Deferred().promise();
|
||||
const action = {
|
||||
type: 'LINK_DWELL',
|
||||
type: actionTypes.LINK_DWELL,
|
||||
el: this.el,
|
||||
event: {},
|
||||
token: '1234567890',
|
||||
|
@ -87,7 +87,7 @@ QUnit.test( 'LINK_DWELL initializes the state for a new link', function ( assert
|
|||
|
||||
QUnit.test( 'LINK_DWELL on an active link only updates dwell state', function ( assert ) {
|
||||
const action = {
|
||||
type: 'LINK_DWELL',
|
||||
type: actionTypes.LINK_DWELL,
|
||||
el: this.el,
|
||||
event: {},
|
||||
token: '1234567890'
|
||||
|
@ -109,7 +109,7 @@ QUnit.test( 'LINK_DWELL on an active link only updates dwell state', function (
|
|||
|
||||
QUnit.test( 'ABANDON_END', ( assert ) => {
|
||||
const action = {
|
||||
type: 'ABANDON_END',
|
||||
type: actionTypes.ABANDON_END,
|
||||
token: 'bananas'
|
||||
};
|
||||
let state = {
|
||||
|
@ -164,7 +164,7 @@ QUnit.test( 'FETCH_COMPLETE', ( assert ) => {
|
|||
isUserDwelling: true
|
||||
},
|
||||
action = {
|
||||
type: 'FETCH_COMPLETE',
|
||||
type: actionTypes.FETCH_COMPLETE,
|
||||
token,
|
||||
result: {}
|
||||
};
|
||||
|
@ -187,7 +187,7 @@ QUnit.test( 'FETCH_COMPLETE', ( assert ) => {
|
|||
// ---
|
||||
|
||||
state = preview( state, {
|
||||
type: 'ABANDON_START',
|
||||
type: actionTypes.ABANDON_START,
|
||||
token
|
||||
} );
|
||||
|
||||
|
@ -206,7 +206,7 @@ QUnit.test( 'FETCH_COMPLETE', ( assert ) => {
|
|||
// ---
|
||||
|
||||
action = {
|
||||
type: 'FETCH_COMPLETE',
|
||||
type: actionTypes.FETCH_COMPLETE,
|
||||
token: 'banana',
|
||||
result: {}
|
||||
};
|
||||
|
@ -264,7 +264,7 @@ QUnit.test( actionTypes.FETCH_FAILED, ( assert ) => {
|
|||
|
||||
QUnit.test( 'PREVIEW_DWELL', ( assert ) => {
|
||||
const action = {
|
||||
type: 'PREVIEW_DWELL'
|
||||
type: actionTypes.PREVIEW_DWELL
|
||||
};
|
||||
|
||||
assert.expect( 1, 'All assertions are executed.' );
|
||||
|
@ -280,7 +280,7 @@ QUnit.test( 'PREVIEW_DWELL', ( assert ) => {
|
|||
|
||||
QUnit.test( 'ABANDON_START', ( assert ) => {
|
||||
const action = {
|
||||
type: 'ABANDON_START'
|
||||
type: actionTypes.ABANDON_START
|
||||
};
|
||||
|
||||
assert.deepEqual(
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import settings from '../../../src/reducers/settings';
|
||||
import actionTypes from '../../../src/actionTypes';
|
||||
|
||||
QUnit.module( 'reducers/settings' );
|
||||
|
||||
|
@ -18,7 +19,7 @@ QUnit.test( '@@INIT', ( assert ) => {
|
|||
|
||||
QUnit.test( 'BOOT', ( assert ) => {
|
||||
const action = {
|
||||
type: 'BOOT',
|
||||
type: actionTypes.BOOT,
|
||||
isEnabled: false,
|
||||
user: {
|
||||
isAnon: true
|
||||
|
@ -51,7 +52,7 @@ QUnit.test( 'SETTINGS_SHOW', ( assert ) => {
|
|||
assert.expect( 1, 'All assertions are executed.' );
|
||||
|
||||
assert.deepEqual(
|
||||
settings( {}, { type: 'SETTINGS_SHOW' } ),
|
||||
settings( {}, { type: actionTypes.SETTINGS_SHOW } ),
|
||||
{
|
||||
shouldShow: true,
|
||||
showHelp: false
|
||||
|
@ -64,7 +65,7 @@ QUnit.test( 'SETTINGS_HIDE', ( assert ) => {
|
|||
assert.expect( 1, 'All assertions are executed.' );
|
||||
|
||||
assert.deepEqual(
|
||||
settings( {}, { type: 'SETTINGS_HIDE' } ),
|
||||
settings( {}, { type: actionTypes.SETTINGS_HIDE } ),
|
||||
{
|
||||
shouldShow: false,
|
||||
showHelp: false
|
||||
|
@ -76,7 +77,7 @@ QUnit.test( 'SETTINGS_HIDE', ( assert ) => {
|
|||
QUnit.test( 'SETTINGS_CHANGE', ( assert ) => {
|
||||
const action = ( wasEnabled, enabled ) => {
|
||||
return {
|
||||
type: 'SETTINGS_CHANGE',
|
||||
type: actionTypes.SETTINGS_CHANGE,
|
||||
wasEnabled,
|
||||
enabled
|
||||
};
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import statsv from '../../../src/reducers/statsv';
|
||||
import actionTypes from '../../../src/actionTypes';
|
||||
|
||||
QUnit.module( 'ext.popups/reducers#eventLogging', {
|
||||
beforeEach() {
|
||||
|
@ -18,7 +19,7 @@ QUnit.test( 'FETCH_START', function ( assert ) {
|
|||
assert.expect( 1, 'All assertions are executed.' );
|
||||
|
||||
const action = {
|
||||
type: 'FETCH_START',
|
||||
type: actionTypes.FETCH_START,
|
||||
timestamp: 123
|
||||
};
|
||||
const state = statsv( this.initialState, action );
|
||||
|
@ -38,7 +39,7 @@ QUnit.test( 'FETCH_END', ( assert ) => {
|
|||
const startedAt = 200;
|
||||
const endedAt = 500;
|
||||
const action = {
|
||||
type: 'FETCH_END',
|
||||
type: actionTypes.FETCH_END,
|
||||
timestamp: endedAt
|
||||
};
|
||||
const state = statsv( { fetchStartedAt: startedAt }, action );
|
||||
|
@ -58,7 +59,7 @@ QUnit.test( 'FETCH_FAILED', ( assert ) => {
|
|||
assert.expect( 1, 'All assertions are executed.' );
|
||||
|
||||
const action = {
|
||||
type: 'FETCH_FAILED'
|
||||
type: actionTypes.FETCH_FAILED
|
||||
};
|
||||
const state = statsv( {}, action );
|
||||
|
||||
|
@ -77,7 +78,7 @@ QUnit.test( 'LINK_DWELL', ( assert ) => {
|
|||
|
||||
const timestamp = 100;
|
||||
const action = {
|
||||
type: 'LINK_DWELL',
|
||||
type: actionTypes.LINK_DWELL,
|
||||
timestamp
|
||||
};
|
||||
const state = statsv( {}, action );
|
||||
|
@ -97,7 +98,7 @@ QUnit.test( 'PREVIEW_SHOW', ( assert ) => {
|
|||
const startedAt = 100;
|
||||
const endedAt = 300;
|
||||
const action = {
|
||||
type: 'PREVIEW_SHOW',
|
||||
type: actionTypes.PREVIEW_SHOW,
|
||||
timestamp: endedAt
|
||||
};
|
||||
const state = statsv( { linkDwellStartedAt: startedAt }, action );
|
||||
|
@ -117,7 +118,7 @@ QUnit.test( 'STATSV_LOGGED', ( assert ) => {
|
|||
assert.expect( 1, 'All assertions are executed.' );
|
||||
|
||||
const action = {
|
||||
type: 'STATSV_LOGGED'
|
||||
type: actionTypes.STATSV_LOGGED
|
||||
};
|
||||
const state = statsv( { data: 123 }, action );
|
||||
|
||||
|
|
Loading…
Reference in a new issue