Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Jan 8, 2019
1 parent 7c3028c commit 38d373d
Show file tree
Hide file tree
Showing 21 changed files with 5,863 additions and 6,287 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,17 @@ Whether redo history exists.

## Actions

### initBlocks

Returns an action object used in signalling that blocks state should be
intialized using a specified array of blocks,

This action reset the undo/redo history

*Parameters*

* blocks: Array of blocks.

### resetBlocks

Returns an action object used in signalling that blocks state should be
Expand Down Expand Up @@ -1019,4 +1030,14 @@ Returns an action object used in signalling that undo history should pop.
### createUndoLevel

Returns an action object used in signalling that undo history record should
be created.
be created.

### __unstableSaveResuableBlock

Returns an action object used in signalling that a temporary reusable blocks have been saved
in order to switch its temporary id with the real id.

*Parameters*

* id: Reusable block's id.
* updatedId: Updated block's id.
26 changes: 12 additions & 14 deletions docs/designers-developers/developers/data/data-core-editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -584,19 +584,6 @@ before state satisfies the given predicate function.

Whether predicate matches for some history.

### getBlockListSettings

Returns the Block List settings of a block, if any exist.

*Parameters*

* state: Editor state.
* clientId: Block client ID.

*Returns*

Block settings of the block if set.

### isPostLocked

Returns whether the post is locked.
Expand Down Expand Up @@ -694,6 +681,18 @@ Return the current block list.

Block list.

### isEditorReady

Is the editor ready

*Parameters*

* state: null

*Returns*

is Ready.

## Actions

### setupEditor
Expand Down Expand Up @@ -741,7 +740,6 @@ Returns an action object used to setup the editor state when first opening an ed
*Parameters*

* post: Post object.
* blocks: Array of blocks.

### editPost

Expand Down
1 change: 1 addition & 0 deletions lib/packages-dependencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
'wp-data',
'wp-element',
'wp-i18n',
'wp-notices',
),
'wp-blocks' => array(
'lodash',
Expand Down
3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/block-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@wordpress/data": "file:../data",
"@wordpress/element": "file:../element",
"@wordpress/i18n": "file:../i18n",
"@wordpress/notices": "file:../notices",
"lodash": "^4.17.10",
"refx": "^3.0.0",
"rememo": "^3.0.0"
Expand Down
1 change: 1 addition & 0 deletions packages/block-editor/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/

import '@wordpress/blocks';
import '@wordpress/notices';

/**
* Internal dependencies
Expand Down
39 changes: 1 addition & 38 deletions packages/block-editor/src/store/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
keys,
isEqual,
isEmpty,
overSome,
get,
} from 'lodash';

Expand All @@ -32,22 +31,6 @@ import {
} from './defaults';
import { insertAt, moveTo } from './array';

/**
* Returns a post attribute value, flattening nested rendered content using its
* raw value in place of its original object form.
*
* @param {*} value Original value.
*
* @return {*} Raw value.
*/
export function getPostRawValue( value ) {
if ( value && 'object' === typeof value && 'raw' in value ) {
return value.raw;
}

return value;
}

/**
* Given an array of blocks, returns an object where each key is a nesting
* context, the value of which is an array of block client IDs existing within
Expand Down Expand Up @@ -191,23 +174,6 @@ export function isUpdatingSameBlockAttribute( action, previousAction ) {
);
}

/**
* Returns true if, given the currently dispatching action and the previously
* dispatched action, the two actions are editing the same post property, or
* false otherwise.
*
* @param {Object} action Currently dispatching action.
* @param {Object} previousAction Previously dispatched action.
*
* @return {boolean} Whether actions are updating the same post property.
*/
export function isUpdatingSamePostProperty( action, previousAction ) {
return (
action.type === 'EDIT_POST' &&
hasSameKeys( action.edits, previousAction.edits )
);
}

/**
* Returns true if, given the currently dispatching action and the previously
* dispatched action, the two actions are modifying the same property such that
Expand All @@ -223,10 +189,7 @@ export function shouldOverwriteState( action, previousAction ) {
return false;
}

return overSome( [
isUpdatingSameBlockAttribute,
isUpdatingSamePostProperty,
] )( action, previousAction );
return isUpdatingSameBlockAttribute( action, previousAction );
}

/**
Expand Down
Loading

0 comments on commit 38d373d

Please sign in to comment.