From de03557689bbc54465627b853424cd35caed0397 Mon Sep 17 00:00:00 2001 From: hideokamoto Date: Sun, 3 Dec 2017 12:56:10 -0600 Subject: [PATCH 1/6] load all editor actions --- editor/test/actions.js | 44 ++++++++++++++---------------------------- 1 file changed, 15 insertions(+), 29 deletions(-) diff --git a/editor/test/actions.js b/editor/test/actions.js index cc8b8d05f917f5..f2a88b038bde41 100644 --- a/editor/test/actions.js +++ b/editor/test/actions.js @@ -1,21 +1,7 @@ /** * Internal dependencies */ -import { - focusBlock, - replaceBlocks, - startTyping, - stopTyping, - requestMetaBoxUpdates, - handleMetaBoxReload, - metaBoxStateChanged, - initializeMetaBoxState, - fetchReusableBlocks, - updateReusableBlock, - saveReusableBlock, - convertBlockToStatic, - convertBlockToReusable, -} from '../actions'; +import * as actions from '../actions'; describe( 'actions', () => { describe( 'focusBlock', () => { @@ -24,7 +10,7 @@ describe( 'actions', () => { editable: 'cite', }; - expect( focusBlock( 'chicken', focusConfig ) ).toEqual( { + expect( actions.focusBlock( 'chicken', focusConfig ) ).toEqual( { type: 'UPDATE_FOCUS', uid: 'chicken', config: focusConfig, @@ -38,7 +24,7 @@ describe( 'actions', () => { uid: 'ribs', } ]; - expect( replaceBlocks( [ 'chicken' ], blocks ) ).toEqual( { + expect( actions.replaceBlocks( [ 'chicken' ], blocks ) ).toEqual( { type: 'REPLACE_BLOCKS', uids: [ 'chicken' ], blocks, @@ -48,7 +34,7 @@ describe( 'actions', () => { describe( 'startTyping', () => { it( 'should return the START_TYPING action', () => { - expect( startTyping() ).toEqual( { + expect( actions.startTyping() ).toEqual( { type: 'START_TYPING', } ); } ); @@ -56,7 +42,7 @@ describe( 'actions', () => { describe( 'stopTyping', () => { it( 'should return the STOP_TYPING action', () => { - expect( stopTyping() ).toEqual( { + expect( actions.stopTyping() ).toEqual( { type: 'STOP_TYPING', } ); } ); @@ -64,7 +50,7 @@ describe( 'actions', () => { describe( 'requestMetaBoxUpdates', () => { it( 'should return the REQUEST_META_BOX_UPDATES action', () => { - expect( requestMetaBoxUpdates( [ 'normal' ] ) ).toEqual( { + expect( actions.requestMetaBoxUpdates( [ 'normal' ] ) ).toEqual( { type: 'REQUEST_META_BOX_UPDATES', locations: [ 'normal' ], } ); @@ -73,7 +59,7 @@ describe( 'actions', () => { describe( 'handleMetaBoxReload', () => { it( 'should return the HANDLE_META_BOX_RELOAD action with a location and node', () => { - expect( handleMetaBoxReload( 'normal' ) ).toEqual( { + expect( actions.handleMetaBoxReload( 'normal' ) ).toEqual( { type: 'HANDLE_META_BOX_RELOAD', location: 'normal', } ); @@ -82,7 +68,7 @@ describe( 'actions', () => { describe( 'metaBoxStateChanged', () => { it( 'should return the META_BOX_STATE_CHANGED action with a hasChanged flag', () => { - expect( metaBoxStateChanged( 'normal', true ) ).toEqual( { + expect( actions.metaBoxStateChanged( 'normal', true ) ).toEqual( { type: 'META_BOX_STATE_CHANGED', location: 'normal', hasChanged: true, @@ -98,7 +84,7 @@ describe( 'actions', () => { advanced: false, }; - expect( initializeMetaBoxState( metaBoxes ) ).toEqual( { + expect( actions.initializeMetaBoxState( metaBoxes ) ).toEqual( { type: 'INITIALIZE_META_BOX_STATE', metaBoxes, } ); @@ -107,14 +93,14 @@ describe( 'actions', () => { describe( 'fetchReusableBlocks', () => { it( 'should return the FETCH_REUSABLE_BLOCKS action', () => { - expect( fetchReusableBlocks() ).toEqual( { + expect( actions.fetchReusableBlocks() ).toEqual( { type: 'FETCH_REUSABLE_BLOCKS', } ); } ); it( 'should take an optional id argument', () => { const id = '358b59ee-bab3-4d6f-8445-e8c6971a5605'; - expect( fetchReusableBlocks( id ) ).toEqual( { + expect( actions.fetchReusableBlocks( id ) ).toEqual( { type: 'FETCH_REUSABLE_BLOCKS', id, } ); @@ -132,7 +118,7 @@ describe( 'actions', () => { content: 'Hello!', }, }; - expect( updateReusableBlock( id, reusableBlock ) ).toEqual( { + expect( actions.updateReusableBlock( id, reusableBlock ) ).toEqual( { type: 'UPDATE_REUSABLE_BLOCK', id, reusableBlock, @@ -142,7 +128,7 @@ describe( 'actions', () => { describe( 'saveReusableBlock', () => { const id = '358b59ee-bab3-4d6f-8445-e8c6971a5605'; - expect( saveReusableBlock( id ) ).toEqual( { + expect( actions.saveReusableBlock( id ) ).toEqual( { type: 'SAVE_REUSABLE_BLOCK', id, } ); @@ -150,7 +136,7 @@ describe( 'actions', () => { describe( 'convertBlockToStatic', () => { const uid = '358b59ee-bab3-4d6f-8445-e8c6971a5605'; - expect( convertBlockToStatic( uid ) ).toEqual( { + expect( actions.convertBlockToStatic( uid ) ).toEqual( { type: 'CONVERT_BLOCK_TO_STATIC', uid, } ); @@ -158,7 +144,7 @@ describe( 'actions', () => { describe( 'convertBlockToReusable', () => { const uid = '358b59ee-bab3-4d6f-8445-e8c6971a5605'; - expect( convertBlockToReusable( uid ) ).toEqual( { + expect( actions.convertBlockToReusable( uid ) ).toEqual( { type: 'CONVERT_BLOCK_TO_REUSABLE', uid, } ); From 84a9f507f313ba052d3c89e94e70afc97e3936f4 Mon Sep 17 00:00:00 2001 From: hideokamoto Date: Sun, 3 Dec 2017 14:16:49 -0600 Subject: [PATCH 2/6] add actions test(line1 to line 367) --- editor/test/actions.js | 320 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 320 insertions(+) diff --git a/editor/test/actions.js b/editor/test/actions.js index f2a88b038bde41..781aed7f847d1d 100644 --- a/editor/test/actions.js +++ b/editor/test/actions.js @@ -4,6 +4,72 @@ import * as actions from '../actions'; describe( 'actions', () => { + describe( 'setupEditor', () => { + it( 'should return the SETUP_EDITOR action', () => { + const post = {}; + const settings = {}; + const result = actions.setupEditor( post, settings ); + expect( result ).toEqual( { + type: 'SETUP_EDITOR', + post: {}, + settings: {}, + } ); + } ); + } ); + describe( 'resetPost', () => { + it( 'should return the RESET_POST action', () => { + const post = {}; + const result = actions.resetPost( post ); + expect( result ).toEqual( { + type: 'RESET_POST', + post: {}, + } ); + } ); + } ); + describe( 'setupNewPost', () => { + it( 'should return the SETUP_NEW_POST action', () => { + const edits = {}; + const result = actions.setupNewPost( edits ); + expect( result ).toEqual( { + type: 'SETUP_NEW_POST', + edits: {}, + } ); + } ); + } ); + describe( 'resetBlocks', () => { + it( 'should return the RESET_BLOCKS actions', () => { + const blocks = []; + const result = actions.resetBlocks( blocks ); + expect( result ).toEqual( { + type: 'RESET_BLOCKS', + blocks: [], + } ); + } ); + } ); + describe( 'updateBlockAttributes', () => { + it( 'should return the UPDATE_BLOCK_ATTRIBUTES action', () => { + const uid = 'string'; + const attributes = {}; + const result = actions.updateBlockAttributes( uid, attributes ); + expect( result ).toEqual( { + type: 'UPDATE_BLOCK_ATTRIBUTES', + uid: 'string', + attributes: {}, + } ); + } ); + } ); + describe( 'updateBlock', () => { + it( 'should return the UPDATE_BLOCK action', () => { + const uid = 'uid'; + const updates = {}; + const result = actions.updateBlock( uid, updates ); + expect( result ).toEqual( { + type: 'UPDATE_BLOCK', + uid: 'uid', + updates: {}, + } ); + } ); + } ); describe( 'focusBlock', () => { it( 'should return the UPDATE_FOCUS action', () => { const focusConfig = { @@ -18,6 +84,61 @@ describe( 'actions', () => { } ); } ); + describe( 'selectBlock', () => { + it( 'should return the SELECT_BLOCK action', () => { + const uid = 'uid'; + const result = actions.selectBlock( uid ); + expect( result ).toEqual( { + type: 'SELECT_BLOCK', + uid: 'uid', + } ); + } ); + } ); + describe( 'startMultiSelect', () => { + it( 'should return the START_MULTI_SELECT', () => { + expect( actions.startMultiSelect() ).toEqual( { + type: 'START_MULTI_SELECT', + } ); + } ); + } ); + describe( 'stopMultiSelect', () => { + it( 'should return the Stop_MULTI_SELECT', () => { + expect( actions.stopMultiSelect() ).toEqual( { + type: 'STOP_MULTI_SELECT', + } ); + } ); + } ); + describe( 'multiSelect', () => { + it( 'should return MULTI_SELECT action', () => { + const start = 'start'; + const end = 'end'; + expect( actions.multiSelect( start, end ) ).toEqual( { + type: 'MULTI_SELECT', + start: 'start', + end: 'end', + } ); + } ); + } ); + describe( 'clearSelectedBlock', () => { + it( 'should return CLEAR_SELECTED_BLOCK action', () => { + expect( actions.clearSelectedBlock() ).toEqual( { + type: 'CLEAR_SELECTED_BLOCK', + } ); + } ); + } ); + describe( 'replaceBlock', () => { + it( 'should return the REPLACE_BLOCKS action', () => { + const blocks = { + uid: 'ribs', + }; + + expect( actions.replaceBlock( [ 'chicken' ], blocks ) ).toEqual( { + type: 'REPLACE_BLOCKS', + uids: [ 'chicken' ], + blocks: [ blocks ], + } ); + } ); + } ); describe( 'replaceBlocks', () => { it( 'should return the REPLACE_BLOCKS action', () => { const blocks = [ { @@ -32,6 +153,178 @@ describe( 'actions', () => { } ); } ); + describe( 'insertBlock', () => { + it( 'should return the INSERT_BLOCKS action', () => { + const block = { + uid: 'ribs', + }; + const position = 'position'; + expect( actions.insertBlock( block, position ) ).toEqual( { + type: 'INSERT_BLOCKS', + blocks: [ + { + uid: 'ribs', + }, + ], + position: 'position', + } ); + } ); + } ); + describe( 'insertBlocks', () => { + it( 'should return the INSERT_BLOCKS action', () => { + const block = [ { + uid: 'ribs', + } ]; + const position = 'position'; + expect( actions.insertBlocks( block, position ) ).toEqual( { + type: 'INSERT_BLOCKS', + blocks: [ + { + uid: 'ribs', + }, + ], + position: 'position', + } ); + } ); + } ); + + describe( 'showInsertionPoint', () => { + it( 'should return the SHOW_INSERTION_POINT action', () => { + expect( actions.showInsertionPoint() ).toEqual( { + type: 'SHOW_INSERTION_POINT', + } ); + } ); + } ); + describe( 'hideInsertionPoint', () => { + it( 'should return the HIDE_INSERTION_POINT action', () => { + expect( actions.hideInsertionPoint() ).toEqual( { + type: 'HIDE_INSERTION_POINT', + } ); + } ); + } ); + + describe( 'setBlockInsertionPoint', () => { + it( 'should return the SET_BLOCK_INSERTION_POINT action', () => { + const position = 1; + expect( actions.setBlockInsertionPoint( position ) ).toEqual( { + type: 'SET_BLOCK_INSERTION_POINT', + position: 1, + } ); + } ); + } ); + + describe( 'clearBlockInsertionPoint', () => { + it( 'should return the CLEAR_BLOCK_INSERTION_POINT action', () => { + expect( actions.clearBlockInsertionPoint() ).toEqual( { + type: 'CLEAR_BLOCK_INSERTION_POINT', + } ); + } ); + } ); + + describe( 'editPost', () => { + it( 'should return EDIT_POST action', () => { + const edits = { format: 'sample' }; + expect( actions.editPost( edits ) ).toEqual( { + type: 'EDIT_POST', + edits: { + format: 'sample', + }, + } ); + } ); + } ); + + describe( 'savePost', () => { + it( 'should return REQUEST_POST_UPDATE action', () => { + expect( actions.savePost() ).toEqual( { + type: 'REQUEST_POST_UPDATE', + } ); + } ); + } ); + describe( 'trashPost', () => { + it( 'should return TRASH_POST action', () => { + const postId = 1; + const postType = 'post'; + expect( actions.trashPost( postId, postType ) ).toEqual( { + type: 'TRASH_POST', + postId: 1, + postType: 'post', + } ); + } ); + } ); + describe( 'mergeBlocks', () => { + it( 'should return MERGE_BLOCKS action', () => { + const blockA = { + uid: 'blockA', + }; + const blockB = { + uid: 'blockB', + }; + expect( actions.mergeBlocks( blockA, blockB ) ).toEqual( { + type: 'MERGE_BLOCKS', + blocks: [ { + uid: 'blockA', + }, { + uid: 'blockB', + } ], + } ); + } ); + } ); + + describe( 'autosave', () => { + it( 'should return AUTOSAVE action', () => { + expect( actions.autosave() ).toEqual( { + type: 'AUTOSAVE', + } ); + } ); + } ); + describe( 'redo', () => { + it( 'should return REDO action', () => { + expect( actions.redo() ).toEqual( { + type: 'REDO', + } ); + } ); + } ); + describe( 'undo', () => { + it( 'should return UNDO action', () => { + expect( actions.undo() ).toEqual( { + type: 'UNDO', + } ); + } ); + } ); + + describe( 'removeBlocks', () => { + it( 'should return REMOVE_BLOCKS action', () => { + const uids = [ 'uid' ]; + expect( actions.removeBlocks( uids ) ).toEqual( { + type: 'REMOVE_BLOCKS', + uids: [ + 'uid', + ], + } ); + } ); + } ); + describe( 'removeBlock', () => { + it( 'should return REMOVE_BLOCKS action', () => { + const uid = 'uid'; + expect( actions.removeBlock( uid ) ).toEqual( { + type: 'REMOVE_BLOCKS', + uids: [ + 'uid', + ], + } ); + } ); + } ); + + describe( 'toggleBlockMode', () => { + it( 'should return TOGGLE_BLOCK_MODE action', () => { + const uid = 'uid'; + expect( actions.toggleBlockMode( uid ) ).toEqual( { + type: 'TOGGLE_BLOCK_MODE', + uid: 'uid', + } ); + } ); + } ); + describe( 'startTyping', () => { it( 'should return the START_TYPING action', () => { expect( actions.startTyping() ).toEqual( { @@ -48,6 +341,33 @@ describe( 'actions', () => { } ); } ); + describe( 'toggleSidebar', () => { + it( 'should return TOGGLE_SIDEBAR action', () => { + const isMobile = true; + expect( actions.toggleSidebar( isMobile ) ).toEqual( { + type: 'TOGGLE_SIDEBAR', + isMobile: true, + } ); + } ); + } ); + + describe( 'setActivePanel', () => { + const panel = 'panelName'; + expect( actions.setActivePanel( panel ) ).toEqual( { + type: 'SET_ACTIVE_PANEL', + panel: 'panelName', + } ); + } ); + describe( 'toggleSidebarPanel', () => { + it( 'should return TOGGLE_SIDEBAR_PANEL action', () => { + const panel = 'panelName'; + expect( actions.toggleSidebarPanel( panel ) ).toEqual( { + type: 'TOGGLE_SIDEBAR_PANEL', + panel: 'panelName', + } ); + } ); + } ); + describe( 'requestMetaBoxUpdates', () => { it( 'should return the REQUEST_META_BOX_UPDATES action', () => { expect( actions.requestMetaBoxUpdates( [ 'normal' ] ) ).toEqual( { From a25456858a0d50e9333fbd108e4e33f7059a9c58 Mon Sep 17 00:00:00 2001 From: hideokamoto Date: Sun, 3 Dec 2017 14:48:19 -0600 Subject: [PATCH 3/6] add all editor/action's test --- editor/test/actions.js | 98 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/editor/test/actions.js b/editor/test/actions.js index 781aed7f847d1d..2838dba3e55240 100644 --- a/editor/test/actions.js +++ b/editor/test/actions.js @@ -368,6 +368,104 @@ describe( 'actions', () => { } ); } ); + describe( 'createNotice', () => { + const status = 'status'; + const content =

element

; + it( 'should return CREATE_NOTICE action when options is empty', () => { + const result = actions.createNotice( status, content ); + expect( result.type ).toEqual( 'CREATE_NOTICE' ); + expect( result.notice.status ).toEqual( 'status' ); + expect( result.notice.content ).toEqual(

element

); + expect( result.notice.isDismissible ).toEqual( true ); + expect( result.notice.id ).toBeDefined(); + } ); + it( 'should return CREATE_NOTICE action when options is desined', () => { + const options = { + id: 'id', + isDismissible: false, + }; + const result = actions.createNotice( status, content, options ); + expect( result ).toEqual( { + type: 'CREATE_NOTICE', + notice: { + id: 'id', + status: 'status', + content:

element

, + isDismissible: false, + }, + } ); + } ); + } ); + describe( 'createSuccessNotice', () => { + it( 'should return CREATE_NOTICE action', () => { + const result = actions.createSuccessNotice(

element

); + expect( result.type ).toEqual( 'CREATE_NOTICE' ); + expect( result.notice.status ).toEqual( 'success' ); + expect( result.notice.content ).toEqual(

element

); + expect( result.notice.isDismissible ).toEqual( true ); + expect( result.notice.id ).toBeDefined(); + } ); + } ); + describe( 'createInfoNotice', () => { + it( 'should return CREATE_NOTICE action', () => { + const result = actions.createInfoNotice(

element

); + expect( result.type ).toEqual( 'CREATE_NOTICE' ); + expect( result.notice.status ).toEqual( 'info' ); + expect( result.notice.content ).toEqual(

element

); + expect( result.notice.isDismissible ).toEqual( true ); + expect( result.notice.id ).toBeDefined(); + } ); + } ); + describe( 'createErrorNotice', () => { + it( 'should return CREATE_NOTICE action', () => { + const result = actions.createErrorNotice(

element

); + expect( result.type ).toEqual( 'CREATE_NOTICE' ); + expect( result.notice.status ).toEqual( 'error' ); + expect( result.notice.content ).toEqual(

element

); + expect( result.notice.isDismissible ).toEqual( true ); + expect( result.notice.id ).toBeDefined(); + } ); + } ); + describe( 'createWarningNotice', () => { + it( 'should return CREATE_NOTICE action', () => { + const result = actions.createWarningNotice(

element

); + expect( result.type ).toEqual( 'CREATE_NOTICE' ); + expect( result.notice.status ).toEqual( 'warning' ); + expect( result.notice.content ).toEqual(

element

); + expect( result.notice.isDismissible ).toEqual( true ); + expect( result.notice.id ).toBeDefined(); + } ); + } ); + describe( 'removeNotice', () => { + it( 'should return REMOVE_NOTICE actions', () => { + const id = 'id'; + expect( actions.removeNotice( id ) ).toEqual( { + type: 'REMOVE_NOTICE', + noticeId: 'id', + } ); + } ); + } ); + + describe( 'metaBoxLoaded', () => { + it( 'should return META_BOX_LOADED action', () => { + const location = 'normal'; + expect( actions.metaBoxLoaded( location ) ).toEqual( { + type: 'META_BOX_LOADED', + location: 'normal', + } ); + } ); + } ); + + describe( 'toggleFeature', () => { + it( 'should return TOGGLE_FEATURE action', () => { + const feature = 'name'; + expect( actions.toggleFeature( feature ) ).toEqual( { + type: 'TOGGLE_FEATURE', + feature: 'name', + } ); + } ); + } ); + describe( 'requestMetaBoxUpdates', () => { it( 'should return the REQUEST_META_BOX_UPDATES action', () => { expect( actions.requestMetaBoxUpdates( [ 'normal' ] ) ).toEqual( { From f54d8cd226beece14465d2a96e6ac82d7c2549e4 Mon Sep 17 00:00:00 2001 From: hideokamoto Date: Thu, 7 Dec 2017 23:26:04 +0900 Subject: [PATCH 4/6] remove prefix to loading actions function --- editor/test/actions.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/editor/test/actions.js b/editor/test/actions.js index 7876cf279f391c..447929f7c0d912 100644 --- a/editor/test/actions.js +++ b/editor/test/actions.js @@ -16,6 +16,45 @@ import { convertBlockToStatic, convertBlockToReusable, toggleSelection, + setupEditor, + resetPost, + setupNewPost, + resetBlocks, + updateBlockAttributes, + updateBlock, + selectBlock, + startMultiSelect, + stopMultiSelect, + multiSelect, + clearSelectedBlock, + replaceBlock, + insertBlock, + insertBlocks, + showInsertionPoint, + hideInsertionPoint, + setBlockInsertionPoint, + clearBlockInsertionPoint, + editPost, + savePost, + trashPost, + mergeBlocks, + autosave, + redo, + undo, + removeBlocks, + removeBlock, + toggleBlockMode, + toggleSidebar, + setActivePanel, + toggleSidebarPanel, + createNotice, + createSuccessNotice, + createInfoNotice, + createErrorNotice, + createWarningNotice, + removeNotice, + metaBoxLoaded, + toggleFeature, } from '../actions'; describe( 'actions', () => { From 60a45c8cd10b985225c936b1d2be066e596b3f14 Mon Sep 17 00:00:00 2001 From: hideokamoto Date: Thu, 7 Dec 2017 23:27:53 +0900 Subject: [PATCH 5/6] rename actions test variables --- editor/test/actions.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/editor/test/actions.js b/editor/test/actions.js index 447929f7c0d912..ec9161031d234e 100644 --- a/editor/test/actions.js +++ b/editor/test/actions.js @@ -182,14 +182,14 @@ describe( 'actions', () => { } ); describe( 'replaceBlock', () => { it( 'should return the REPLACE_BLOCKS action', () => { - const blocks = { + const block = { uid: 'ribs', }; - expect( replaceBlock( [ 'chicken' ], blocks ) ).toEqual( { + expect( replaceBlock( [ 'chicken' ], block ) ).toEqual( { type: 'REPLACE_BLOCKS', uids: [ 'chicken' ], - blocks: [ blocks ], + blocks: [ block ], } ); } ); } ); @@ -492,8 +492,7 @@ describe( 'actions', () => { } ); describe( 'removeNotice', () => { it( 'should return REMOVE_NOTICE actions', () => { - const id = 'id'; - expect( removeNotice( id ) ).toEqual( { + expect( removeNotice( 'id' ) ).toEqual( { type: 'REMOVE_NOTICE', noticeId: 'id', } ); From 41540c3db5a27cd722ceaf33ae3a9464c828f17b Mon Sep 17 00:00:00 2001 From: hideokamoto Date: Thu, 7 Dec 2017 23:41:14 +0900 Subject: [PATCH 6/6] use toMatchObject to test CREATE_NOTICE actions --- editor/test/actions.js | 82 +++++++++++++++++++++++++++--------------- 1 file changed, 53 insertions(+), 29 deletions(-) diff --git a/editor/test/actions.js b/editor/test/actions.js index ec9161031d234e..71a0d6004b009c 100644 --- a/editor/test/actions.js +++ b/editor/test/actions.js @@ -427,11 +427,15 @@ describe( 'actions', () => { const content =

element

; it( 'should return CREATE_NOTICE action when options is empty', () => { const result = createNotice( status, content ); - expect( result.type ).toEqual( 'CREATE_NOTICE' ); - expect( result.notice.status ).toEqual( 'status' ); - expect( result.notice.content ).toEqual(

element

); - expect( result.notice.isDismissible ).toEqual( true ); - expect( result.notice.id ).toBeDefined(); + expect( result ).toMatchObject( { + type: 'CREATE_NOTICE', + notice: { + status, + content, + isDismissible: true, + id: expect.any( String ), + }, + } ); } ); it( 'should return CREATE_NOTICE action when options is desined', () => { const options = { @@ -452,42 +456,62 @@ describe( 'actions', () => { } ); describe( 'createSuccessNotice', () => { it( 'should return CREATE_NOTICE action', () => { - const result = createSuccessNotice(

element

); - expect( result.type ).toEqual( 'CREATE_NOTICE' ); - expect( result.notice.status ).toEqual( 'success' ); - expect( result.notice.content ).toEqual(

element

); - expect( result.notice.isDismissible ).toEqual( true ); - expect( result.notice.id ).toBeDefined(); + const content =

element

; + const result = createSuccessNotice( content ); + expect( result ).toMatchObject( { + type: 'CREATE_NOTICE', + notice: { + status: 'success', + content, + isDismissible: true, + id: expect.any( String ), + }, + } ); } ); } ); describe( 'createInfoNotice', () => { it( 'should return CREATE_NOTICE action', () => { - const result = createInfoNotice(

element

); - expect( result.type ).toEqual( 'CREATE_NOTICE' ); - expect( result.notice.status ).toEqual( 'info' ); - expect( result.notice.content ).toEqual(

element

); - expect( result.notice.isDismissible ).toEqual( true ); - expect( result.notice.id ).toBeDefined(); + const content =

element

; + const result = createInfoNotice( content ); + expect( result ).toMatchObject( { + type: 'CREATE_NOTICE', + notice: { + status: 'info', + content, + isDismissible: true, + id: expect.any( String ), + }, + } ); } ); } ); describe( 'createErrorNotice', () => { it( 'should return CREATE_NOTICE action', () => { - const result = createErrorNotice(

element

); - expect( result.type ).toEqual( 'CREATE_NOTICE' ); - expect( result.notice.status ).toEqual( 'error' ); - expect( result.notice.content ).toEqual(

element

); - expect( result.notice.isDismissible ).toEqual( true ); - expect( result.notice.id ).toBeDefined(); + const content =

element

; + const result = createErrorNotice( content ); + expect( result ).toMatchObject( { + type: 'CREATE_NOTICE', + notice: { + status: 'error', + content, + isDismissible: true, + id: expect.any( String ), + }, + } ); } ); } ); describe( 'createWarningNotice', () => { it( 'should return CREATE_NOTICE action', () => { - const result = createWarningNotice(

element

); - expect( result.type ).toEqual( 'CREATE_NOTICE' ); - expect( result.notice.status ).toEqual( 'warning' ); - expect( result.notice.content ).toEqual(

element

); - expect( result.notice.isDismissible ).toEqual( true ); - expect( result.notice.id ).toBeDefined(); + const content =

element

; + const result = createWarningNotice( content ); + expect( result ).toMatchObject( { + type: 'CREATE_NOTICE', + notice: { + status: 'warning', + content, + isDismissible: true, + id: expect.any( String ), + }, + } ); } ); } ); describe( 'removeNotice', () => {