diff --git a/components/card/__tests__/index.test.js b/components/card/__tests__/index.test.js index 1c7155cd85..a4e72031f3 100644 --- a/components/card/__tests__/index.test.js +++ b/components/card/__tests__/index.test.js @@ -3,6 +3,7 @@ import { mount } from 'enzyme'; import Card from '../index'; const delay = timeout => new Promise(resolve => setTimeout(resolve, timeout)); +const testMethod = typeof window !== 'undefined' ? it : xit; describe('Card', () => { function fakeResizeWindowTo(wrapper, width) { @@ -15,7 +16,7 @@ describe('Card', () => { window.resizeTo(width); } - it('resize card will trigger different padding', async () => { + testMethod('resize card will trigger different padding', async () => { const wrapper = mount(xxx); fakeResizeWindowTo(wrapper, 1000); await delay(0); diff --git a/components/modal/index.en-US.md b/components/modal/index.en-US.md index 9b2ed0f8ae..9e3226837b 100644 --- a/components/modal/index.en-US.md +++ b/components/modal/index.en-US.md @@ -39,17 +39,7 @@ and so on. #### Destroy on close > The state of Modal will be preserved at it's component lifecircle. -> If you wish to open it with brand new state everytime, you need to reset state manually. Or simply [give a new key](https://github.com/ant-design/ant-design/issues/4165) to Modal when visible is changed to `true`, React will treat it as a new component. - -> ```jsx -> -> ``` - -> Another way is to conditionally mount modal. - -> ```jsx -> {this.state.visible && } -> ``` +> If you wish to open it with brand new state everytime, you need to reset state manually. ### Modal.method() diff --git a/components/modal/index.zh-CN.md b/components/modal/index.zh-CN.md index 6f3791ecc1..9abaab5f12 100644 --- a/components/modal/index.zh-CN.md +++ b/components/modal/index.zh-CN.md @@ -38,17 +38,7 @@ title: Modal #### 清空旧数据 > `` 组件有标准的 React 生命周期,关闭后状态不会自动清空。 -> 如果希望每次打开都是新内容,需要自行手动清空旧的状态。或者打开时给 Modal 设置一个[全新的 key](https://github.com/ant-design/ant-design/issues/4165), React 会渲染出一个全新的对话框。 - -> ```jsx -> -> ``` - -> 另一种方式是根据条件加载 Modal。 - -> ```jsx -> {this.state.visible && } -> ``` +> 如果希望每次打开都是新内容,需要自行手动清空旧的状态。 ### Modal.method() diff --git a/tests/setup.js b/tests/setup.js index 5a895ae2d2..2dfefb0cd4 100644 --- a/tests/setup.js +++ b/tests/setup.js @@ -12,18 +12,18 @@ if (typeof window !== 'undefined') { }; }; window.matchMedia = window.matchMedia || matchMediaPolyfill; + + const documentHTML = '
'; + global.document = jsdom(documentHTML); + global.window = document.parentWindow; + + global.window.resizeTo = (width, height) => { + global.window.innerWidth = width || global.window.innerWidth; + global.window.innerHeight = height || global.window.innerHeight; + global.window.dispatchEvent(new Event('resize')); + }; } global.requestAnimationFrame = global.requestAnimationFrame || function (cb) { return setTimeout(cb, 0); }; - -const documentHTML = '
'; -global.document = jsdom(documentHTML); -global.window = document.parentWindow; - -global.window.resizeTo = (width, height) => { - global.window.innerWidth = width || global.window.innerWidth; - global.window.innerHeight = height || global.window.innerHeight; - global.window.dispatchEvent(new Event('resize')); -};