Match-id-e16de05a4950c19da839de4c26724b907bb5bfa4

This commit is contained in:
* 2022-02-28 20:52:24 +08:00 committed by *
parent 8d516d8999
commit 9ca4b3851b
3 changed files with 14 additions and 9 deletions

View File

@ -127,10 +127,10 @@ module.exports = {
// runner: "jest-runner",
// The paths to modules that run some code to configure or set up the testing environment before each test
setupFilesAfterEnv: [require.resolve('./scripts/__tests__/jest/setupEnvironment.js')],
setupFiles: [require.resolve('./scripts/__tests__/jest/setupTests.js')],
// A list of paths to modules that run some code to configure or set up the testing framework before each test
setupFiles: [require.resolve('./scripts/__tests__/jest/setupTests.js')],
setupFilesAfterEnv: [require.resolve('./scripts/__tests__/jest/setupEnvironment.js')],
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
// snapshotSerializers: [],

View File

@ -4,7 +4,18 @@ import { act } from 'react-dom/test-utils';
describe('Hook Test', () => {
const { useState, useReducer, useEffect, useLayoutEffect, useContext, useMemo, useCallback, useRef, useImperativeHandle, forwardRef } = React;
const {
useState,
useReducer,
useEffect,
useLayoutEffect,
useContext,
useMemo,
useCallback,
useRef,
useImperativeHandle,
forwardRef
} = React;
const { unmountComponentAtNode } = HorizonDOM;
let container = null;
beforeEach(() => {

View File

@ -88,14 +88,8 @@ describe('useState Hook Test', () => {
});
it('useState的惰性初始化', () => {
//let data = null;
const App = forwardRef((props, ref) => {
const [num, setNum] = useState(() => {
// if (data === null) {
// data = ['initNum'];
// } else {
// data.push('initNum');
// }
Scheduler.unstable_yieldValue(props.initNum);
return props.initNum
});