File size: 1,083 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 |
import { POST_SAVE_SUCCESS } from 'calypso/state/action-types';
import reducer, { postId } from '../reducer';
describe( 'reducer', () => {
test( 'should export expected reducer keys', () => {
expect( Object.keys( reducer( undefined, {} ) ) ).toEqual( [
'postId',
'imageEditor',
'videoEditor',
] );
} );
describe( '#postId()', () => {
test( 'should default to null', () => {
const state = postId( undefined, {} );
expect( state ).toBeNull();
} );
test( 'should update the tracked post id if we save a draft post', () => {
const state = postId( null, {
type: POST_SAVE_SUCCESS,
siteId: 1,
postId: null,
savedPost: {
ID: 184,
},
post: {},
} );
expect( state ).toEqual( 184 );
} );
test( 'should not update the tracked post id if we save a draft post but we already switched the tracked post ID', () => {
const state = postId( 10, {
type: POST_SAVE_SUCCESS,
siteId: 1,
postId: null,
savedPost: {
ID: 184,
},
post: {},
} );
expect( state ).toEqual( 10 );
} );
} );
} );
|