Skip to content

Commit

Permalink
Rename getBlockOrder as getBlockIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed Jun 2, 2017
1 parent f34be75 commit 6f8b9de
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions editor/modes/visual-editor/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
getNextBlock,
getBlock,
getBlockFocus,
getBlockOrder,
getBlockIndex,
isBlockHovered,
isBlockSelected,
isBlockMultiSelected,
Expand Down Expand Up @@ -302,7 +302,7 @@ export default connect(
isHovered: isBlockHovered( state, ownProps.uid ),
focus: getBlockFocus( state, ownProps.uid ),
isTyping: isTypingInBlock( state, ownProps.uid ),
order: getBlockOrder( state, ownProps.uid ),
order: getBlockIndex( state, ownProps.uid ),
};
},
( dispatch, ownProps ) => ( {
Expand Down
6 changes: 3 additions & 3 deletions editor/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ export function getBlockUids( state ) {
* @param {String} uid Block unique ID
* @return {Number} Index at which block exists in order
*/
export function getBlockOrder( state, uid ) {
export function getBlockIndex( state, uid ) {
return state.editor.blockOrder.indexOf( uid );
}

Expand Down Expand Up @@ -341,7 +341,7 @@ export function isLastBlock( state, uid ) {
* @return {Object} Block occurring before specified unique ID
*/
export function getPreviousBlock( state, uid ) {
const order = getBlockOrder( state, uid );
const order = getBlockIndex( state, uid );
return state.editor.blocksByUid[ state.editor.blockOrder[ order - 1 ] ] || null;
}

Expand All @@ -354,7 +354,7 @@ export function getPreviousBlock( state, uid ) {
* @return {Object} Block occurring after specified unique ID
*/
export function getNextBlock( state, uid ) {
const order = getBlockOrder( state, uid );
const order = getBlockIndex( state, uid );
return state.editor.blocksByUid[ state.editor.blockOrder[ order + 1 ] ] || null;
}

Expand Down
6 changes: 3 additions & 3 deletions editor/test/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
getBlockSelectionStart,
getBlockSelectionEnd,
getBlockUids,
getBlockOrder,
getBlockIndex,
isFirstBlock,
isLastBlock,
getPreviousBlock,
Expand Down Expand Up @@ -522,15 +522,15 @@ describe( 'selectors', () => {
} );
} );

describe( 'getBlockOrder', () => {
describe( 'getBlockIndex', () => {
it( 'should return the block order', () => {
const state = {
editor: {
blockOrder: [ 123, 23 ],
},
};

expect( getBlockOrder( state, 23 ) ).to.equal( 1 );
expect( getBlockIndex( state, 23 ) ).to.equal( 1 );
} );
} );

Expand Down

0 comments on commit 6f8b9de

Please sign in to comment.