File size: 1,349 Bytes
1e92f2d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | import { GUIDED_TOUR_UPDATE, ROUTE_SET } from 'calypso/state/action-types';
import { getActionLog, getLastAction } from '../selectors';
describe( 'selectors', () => {
describe( 'getActionLog', () => {
test( 'should initially return one empty list', () => {
const log = getActionLog( {
ui: {
actionLog: [],
},
} );
expect( log ).toEqual( [] );
} );
test( 'should retrieve all actions from the log', () => {
const actions = [
{
type: GUIDED_TOUR_UPDATE,
shouldShow: false,
},
{
type: ROUTE_SET,
path: '/menus/77203074',
},
];
const log = getActionLog( {
ui: {
actionLog: actions,
},
} );
expect( log ).toEqual( actions );
} );
} );
describe( 'getLastAction', () => {
test( 'should return undefined for an empty action log', () => {
const action = getLastAction( {
ui: {
actionLog: [],
},
} );
expect( action ).toBe( false );
} );
test( 'should retrieve the last action from the action log', () => {
const navToMenus = { type: 'ROUTE_SET', path: '/menus', timestamp: 0 };
const navToDesign = { type: 'ROUTE_SET', path: '/themes', timestamp: 1 };
const action = getLastAction( {
ui: {
actionLog: [ navToMenus, navToDesign ],
},
} );
expect( action ).toEqual( navToDesign );
} );
} );
} );
|