Skip to content

Commit

Permalink
Restore isNew property of REQUEST_POST_UPDATE and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nylen committed May 27, 2017
1 parent 4c45d0e commit 2fec04e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions editor/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export function savePost( postId, edits ) {
type: 'REQUEST_POST_UPDATE',
edits,
postId,
isNew: ! postId,
};
}

Expand Down
26 changes: 25 additions & 1 deletion editor/test/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import { expect } from 'chai';
/**
* Internal dependencies
*/
import { focusBlock, replaceBlocks } from '../actions';
import {
focusBlock,
replaceBlocks,
savePost,
} from '../actions';

describe( 'actions', () => {
describe( 'focusBlock', () => {
Expand Down Expand Up @@ -36,4 +40,24 @@ describe( 'actions', () => {
} );
} );
} );

describe( 'savePost', () => {
it( 'should return the REQUEST_POST_UPDATE action for a new post', () => {
expect( savePost( null, { title: 'changed' } ) ).to.eql( {
type: 'REQUEST_POST_UPDATE',
edits: { title: 'changed' },
postId: null,
isNew: true,
} );
} );

it( 'should return the REQUEST_POST_UPDATE action for an existing post', () => {
expect( savePost( 1, { title: 'changed' } ) ).to.eql( {
type: 'REQUEST_POST_UPDATE',
edits: { title: 'changed' },
postId: 1,
isNew: false,
} );
} );
} );
} );

0 comments on commit 2fec04e

Please sign in to comment.