Match-id-251f1b0696b6f7418dcac1d6d9b03e3c85f553f9

This commit is contained in:
* 2022-04-24 10:55:50 +08:00 committed by *
parent 2bff70f3d7
commit 70f4751981
15 changed files with 54 additions and 54 deletions

View File

@ -2,7 +2,7 @@ import * as Horizon from '@cloudsop/horizon/index.ts';
import { getLogUtils } from '../jest/testUtils';
describe('Context Test', () => {
const LogUtils =getLogUtils();
const LogUtils = getLogUtils();
it('Provider及其内部consumer组件都不受制于shouldComponentUpdate函数或者Horizon.memo()', () => {
const LanguageTypes = {
JAVA: 'Java',

View File

@ -12,7 +12,7 @@ describe('useEffect Hook Test', () => {
act,
} = Horizon;
const LogUtils =getLogUtils();
const LogUtils = getLogUtils();
it('简单使用useEffect', () => {
const App = () => {
const [num, setNum] = useState(0);

View File

@ -10,7 +10,7 @@ describe('useImperativeHandle Hook Test', () => {
act,
} = Horizon;
const { unmountComponentAtNode } = Horizon;
const LogUtils =getLogUtils();
const LogUtils = getLogUtils();
it('测试useImperativeHandle', () => {
let App = (props, ref) => {

View File

@ -9,7 +9,7 @@ describe('useLayoutEffect Hook Test', () => {
useLayoutEffect,
act,
} = Horizon;
const LogUtils =getLogUtils();
const LogUtils = getLogUtils();
it('简单使用useLayoutEffect', () => {
const App = () => {
const [num, setNum] = useState(0);

View File

@ -4,8 +4,8 @@ import { Text } from '../../jest/commonComponents';
describe('useMemo Hook Test', () => {
const { useMemo, useState } = Horizon;
const LogUtils =getLogUtils();
const LogUtils = getLogUtils();
it('测试useMemo', () => {
let setMemo;
const App = () => {

View File

@ -4,8 +4,8 @@ import { Text } from '../../jest/commonComponents';
describe('useRef Hook Test', () => {
const { useState, useRef } = Horizon;
const LogUtils =getLogUtils();
const LogUtils = getLogUtils();
it('测试useRef', () => {
const App = () => {
const [num, setNum] = useState(1);

View File

@ -10,7 +10,7 @@ describe('useState Hook Test', () => {
memo,
act,
} = Horizon;
const LogUtils =getLogUtils();
const LogUtils = getLogUtils();
it('简单使用useState', () => {
const App = () => {

View File

@ -2,7 +2,7 @@ import * as Horizon from '@cloudsop/horizon/index.ts';
import { getLogUtils } from '../jest/testUtils';
describe('LifeCycle Test', () => {
const LogUtils =getLogUtils();
const LogUtils = getLogUtils();
describe('LifeCycle function', () => {
it('不能在componentWillMount里setState', () => {
class App extends Horizon.Component {
@ -195,7 +195,7 @@ describe('LifeCycle Test', () => {
return nextState.num !== this.state.num;
}
componentDidUpdate(){
componentDidUpdate() {
LogUtils.log('componentDidUpdate');
}
@ -275,7 +275,7 @@ describe('LifeCycle Test', () => {
expect(container.querySelector('p').innerHTML).toBe('2');
});
it('无论什么原因触发了渲染,只要有渲染就会触发getDerivedStateFromProps',() => {
it('无论什么原因触发了渲染,只要有渲染就会触发getDerivedStateFromProps', () => {
class App extends Horizon.Component {
constructor(props) {
super(props);
@ -306,28 +306,28 @@ describe('LifeCycle Test', () => {
});
it('生命周期执行顺序', () => {
class InnerApp extends Horizon.Component {
class ChildApp extends Horizon.Component {
UNSAFE_componentWillMount() {
LogUtils.log('Inner componentWillMount');
LogUtils.log('Child componentWillMount');
}
componentDidMount() {
LogUtils.log('Inner componentDidMount');
LogUtils.log('Child componentDidMount');
}
UNSAFE_componentWillReceiveProps() {
LogUtils.log('Inner componentWillReceiveProps');
LogUtils.log('Child componentWillReceiveProps');
}
shouldComponentUpdate(nextProps, nextState) {
LogUtils.log('Inner shouldComponentUpdates');
LogUtils.log('Child shouldComponentUpdates');
return this.props.number !== nextProps.number;
}
UNSAFE_componentWillUpdate() {
LogUtils.log('Inner componentWillUpdate');
LogUtils.log('Child componentWillUpdate');
}
componentDidUpdate() {
LogUtils.log('Inner componentDidUpdate');
LogUtils.log('Child componentDidUpdate');
}
componentWillUnmount() {
LogUtils.log('Inner componentWillUnmount');
LogUtils.log('Child componentWillUnmount');
}
render() {
@ -360,7 +360,7 @@ describe('LifeCycle Test', () => {
}
render() {
return <InnerApp number={this.props.num} />;
return <ChildApp number={this.props.num} />;
}
}
@ -368,8 +368,8 @@ describe('LifeCycle Test', () => {
expect(container.textContent).toBe('1');
expect(LogUtils.getAndClear()).toEqual([
'componentWillMount',
'Inner componentWillMount',
'Inner componentDidMount',
'Child componentWillMount',
'Child componentDidMount',
'componentDidMount'
]);
Horizon.render(<App num={2} />, container);
@ -378,40 +378,40 @@ describe('LifeCycle Test', () => {
'componentWillReceiveProps',
'shouldComponentUpdates',
'componentWillUpdate',
'Inner componentWillReceiveProps',
'Inner shouldComponentUpdates',
'Inner componentWillUpdate',
'Inner componentDidUpdate',
'Child componentWillReceiveProps',
'Child shouldComponentUpdates',
'Child componentWillUpdate',
'Child componentDidUpdate',
'componentDidUpdate'
]);
Horizon.unmountComponentAtNode(container);
expect(container.textContent).toBe('');
expect(LogUtils.getAndClear()).toEqual([
'componentWillUnmount',
'Inner componentWillUnmount'
'Child componentWillUnmount'
]);
});
it('新生命周期执行顺序', () => {
class InnerApp extends Horizon.Component {
class ChildApp extends Horizon.Component {
static getDerivedStateFromProps(props, state) {
LogUtils.log('Inner getDerivedStateFromProps');
LogUtils.log('Child getDerivedStateFromProps');
}
componentDidMount() {
LogUtils.log('Inner componentDidMount');
LogUtils.log('Child componentDidMount');
}
shouldComponentUpdate(nextProps, nextState) {
LogUtils.log('Inner shouldComponentUpdates');
LogUtils.log('Child shouldComponentUpdates');
return this.props.number !== nextProps.number;
}
componentDidUpdate() {
LogUtils.log('Inner componentDidUpdate');
LogUtils.log('Child componentDidUpdate');
}
getSnapshotBeforeUpdate() {
LogUtils.log('Inner getSnapshotBeforeUpdate');
LogUtils.log('Child getSnapshotBeforeUpdate');
}
componentWillUnmount() {
LogUtils.log('Inner componentWillUnmount');
LogUtils.log('Child componentWillUnmount');
}
render() {
@ -441,7 +441,7 @@ describe('LifeCycle Test', () => {
}
render() {
return <InnerApp number={this.props.num} />;
return <ChildApp number={this.props.num} />;
}
}
@ -449,8 +449,8 @@ describe('LifeCycle Test', () => {
expect(container.textContent).toBe('1');
expect(LogUtils.getAndClear()).toEqual([
'getDerivedStateFromProps',
'Inner getDerivedStateFromProps',
'Inner componentDidMount',
'Child getDerivedStateFromProps',
'Child componentDidMount',
'componentDidMount'
]);
Horizon.render(<App num={2} />, container);
@ -458,18 +458,18 @@ describe('LifeCycle Test', () => {
expect(LogUtils.getAndClear()).toEqual([
'getDerivedStateFromProps',
'shouldComponentUpdates',
'Inner getDerivedStateFromProps',
'Inner shouldComponentUpdates',
'Inner getSnapshotBeforeUpdate',
'Child getDerivedStateFromProps',
'Child shouldComponentUpdates',
'Child getSnapshotBeforeUpdate',
'getSnapshotBeforeUpdate',
'Inner componentDidUpdate',
'Child componentDidUpdate',
'componentDidUpdate'
]);
Horizon.unmountComponentAtNode(container);
expect(container.textContent).toBe('');
expect(LogUtils.getAndClear()).toEqual([
'componentWillUnmount',
'Inner componentWillUnmount'
'Child componentWillUnmount'
]);
});
});

View File

@ -4,7 +4,7 @@ import { getLogUtils } from '../jest/testUtils';
describe('Dom Input', () => {
const { act } = Horizon;
const LogUtils =getLogUtils();
const LogUtils = getLogUtils();
describe('type checkbox', () => {
it('没有设置checked属性时控制台不会报错', () => {

View File

@ -128,14 +128,14 @@ describe('Dom Textarea', () => {
// 非受控切换为受控
let realNode = Horizon.render(<textarea defaultValue='text' />, container);
expect(realNode.value).toBe('text');
Horizon.render(<textarea value='newtext' onChange={() => {}} />, container);
Horizon.render(<textarea value='newtext' onChange={() => { }} />, container);
expect(realNode.value).toBe('newtext');
Horizon.unmountComponentAtNode(container);
// 受控切换为非受控
realNode = Horizon.render(<textarea value='text' onChange={() => {}} />, container);
realNode = Horizon.render(<textarea value='text' onChange={() => { }} />, container);
expect(realNode.value).toBe('text');
Horizon.render(<textarea defaultValue='newtext' onChange={() => {}} />, container);
Horizon.render(<textarea defaultValue='newtext' onChange={() => { }} />, container);
expect(realNode.value).toBe('text');
});

View File

@ -2,7 +2,7 @@ import * as Horizon from '@cloudsop/horizon/index.ts';
import * as TestUtils from '../jest/testUtils';
describe('事件', () => {
const LogUtils =TestUtils.getLogUtils();
const LogUtils = TestUtils.getLogUtils();
it('根节点挂载全量事件', () => {
const App = () => {
return <div />;

View File

@ -2,8 +2,8 @@ import * as Horizon from '@cloudsop/horizon/index.ts';
import { getLogUtils } from '../jest/testUtils';
describe('合成焦点事件', () => {
const LogUtils =getLogUtils();
const LogUtils = getLogUtils();
it('onFocus', () => {
const realNode = Horizon.render(
<input

View File

@ -2,7 +2,7 @@ import * as Horizon from '@cloudsop/horizon/index.ts';
import { getLogUtils } from '../jest/testUtils';
describe('Keyboard Event', () => {
const LogUtils =getLogUtils();
const LogUtils = getLogUtils();
it('keydown,keypress,keyup的keycode,charcode', () => {
const node = Horizon.render(

View File

@ -2,7 +2,7 @@ import * as Horizon from '@cloudsop/horizon/index.ts';
import { getLogUtils } from '../jest/testUtils';
describe('合成滚轮事件', () => {
const LogUtils =getLogUtils();
const LogUtils = getLogUtils();
it('onWheel', () => {
const realNode = Horizon.render(
@ -36,7 +36,7 @@ describe('合成滚轮事件', () => {
LogUtils.log(e.type + ' handle');
};
const realNode = Horizon.render(
<div onWheel={eventHandler}/>,
<div onWheel={eventHandler} />,
container
);

View File

@ -3,7 +3,7 @@ import { getLogUtils } from './testUtils';
//import failOnConsole from 'jest-fail-on-console';
//failOnConsole();
const LogUtils =getLogUtils();
const LogUtils = getLogUtils();
global.isDev = process.env.NODE_ENV === 'development';
global.container = null;
global.beforeEach(() => {