- Instalaciones:
yarn add --dev jest babel-jest @babel/preset-env @babel/preset-react
yarn add --dev @testing-library/react @types/jest jest-environment-jsdom
- Opcional: Si usamos Fetch API en el proyecto:
| import { createSlice } from '@reduxjs/toolkit'; | |
| export const templateSlice = createSlice({ | |
| name: 'name', | |
| initialState: { | |
| counter: 10 | |
| }, | |
| reducers: { | |
| increment: (state, /* action */ ) => { | |
| //! https://react-redux.js.org/tutorials/quick-start |
| function up_the_count( $count ) { | |
| global $post; | |
| $id = $post->ID; | |
| $post_type = get_post_type($id); | |
| switch ($post_type) { | |
| case 'post': | |
| if ( have_rows( 'content', $id ) ): | |
| while ( have_rows( 'content', $id ) ) : the_row(); | |
| if ( get_row_layout() == 'paragraph_section' ): | |
| $count += count( preg_split( '/\s+/', get_sub_field( 'paragraph' ) ) ); |