From 9ca4b3851b21d038188ed23e80b6ad9d5752b9da Mon Sep 17 00:00:00 2001 From: * <8> Date: Mon, 28 Feb 2022 20:52:24 +0800 Subject: [PATCH] Match-id-e16de05a4950c19da839de4c26724b907bb5bfa4 --- jest.config.js | 4 ++-- .../__tests__/ComponentTest/SimpleUseHook.test.js | 13 ++++++++++++- scripts/__tests__/ComponentTest/UseState.test.js | 6 ------ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/jest.config.js b/jest.config.js index e314fd41..5a341ef2 100644 --- a/jest.config.js +++ b/jest.config.js @@ -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: [], diff --git a/scripts/__tests__/ComponentTest/SimpleUseHook.test.js b/scripts/__tests__/ComponentTest/SimpleUseHook.test.js index 238dc4d4..6155b962 100644 --- a/scripts/__tests__/ComponentTest/SimpleUseHook.test.js +++ b/scripts/__tests__/ComponentTest/SimpleUseHook.test.js @@ -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(() => { diff --git a/scripts/__tests__/ComponentTest/UseState.test.js b/scripts/__tests__/ComponentTest/UseState.test.js index 863fb58f..d843d8b7 100644 --- a/scripts/__tests__/ComponentTest/UseState.test.js +++ b/scripts/__tests__/ComponentTest/UseState.test.js @@ -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 });