Download wp-calypso/client/state/editor/test/reducer.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.08 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/editor/test/reducer.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/state/editor/test/reducer.js
-
curl -L -o reducer.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/editor/test/reducer.js
1.08 kB
| 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 ); | |
| } ); | |
| } ); | |
| } ); | |