From bcde044370211b4a0a1d9904000442ee1703160c Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Wed, 10 Apr 2019 15:14:13 +0200 Subject: [PATCH] write a regresion test --- .../src/SpeedDial/SpeedDial.test.js | 6 +- packages/material-ui/src/Modal/Modal.test.js | 61 ++++++++++--------- 2 files changed, 35 insertions(+), 32 deletions(-) diff --git a/packages/material-ui-lab/src/SpeedDial/SpeedDial.test.js b/packages/material-ui-lab/src/SpeedDial/SpeedDial.test.js index e967f8583126a1..60b1c40474d4ff 100644 --- a/packages/material-ui-lab/src/SpeedDial/SpeedDial.test.js +++ b/packages/material-ui-lab/src/SpeedDial/SpeedDial.test.js @@ -350,8 +350,9 @@ describe('', () => { resetDialToOpen(dialDirection); getDialButton().simulate('keydown', { keyCode: keycodes[firstKey] }); - assert.isTrue( + assert.strictEqual( isActionFocused(firstFocusedAction), + true, `focused action initial ${firstKey} should be ${firstFocusedAction}`, ); @@ -363,8 +364,9 @@ describe('', () => { getActionButton(previousFocusedAction).simulate('keydown', { keyCode: keycodes[arrowKey], }); - assert.isTrue( + assert.strictEqual( isActionFocused(expectedFocusedAction), + true, `focused action after ${combinationUntilNot.join( ',', )} should be ${expectedFocusedAction}`, diff --git a/packages/material-ui/src/Modal/Modal.test.js b/packages/material-ui/src/Modal/Modal.test.js index eb16ff9911f900..f84e36d28bd85a 100644 --- a/packages/material-ui/src/Modal/Modal.test.js +++ b/packages/material-ui/src/Modal/Modal.test.js @@ -376,40 +376,41 @@ describe('', () => { assert.strictEqual(modalNode.getAttribute('aria-hidden'), 'true'); }); - /* Test case for https://github.com/mui-org/material-ui/issues/15180 */ + // Test case for https://github.com/mui-org/material-ui/issues/15180 it('should remove the transition children in the DOM when closed whilst transition status is entering', () => { - const onEntering = spy(); - const onEntered = spy(); - const childrenId = '__Modal_test_js__children__id__'; - const childrenIdSelector = `#${childrenId}`; - const TestCase = props => ( - - - Hello - - - ); - TestCase.propTypes = { open: PropTypes.bool }; + const children =

Hello World

; - const wrapper = mount(); - assert.isFalse(wrapper.exists(childrenIdSelector)); - assert.strictEqual(onEntering.callCount, 0); + class OpenClose extends React.Component { + state = { + open: false, + }; - wrapper.setProps({ open: true }); - wrapper.update(); - assert.isTrue(wrapper.exists(childrenIdSelector)); - assert.strictEqual(onEntering.callCount, 1); - assert.strictEqual(onEntered.callCount, 0); + handleClick = () => { + this.setState({ open: true }, () => { + this.setState({ open: false }); + }); + }; - wrapper.setProps({ open: false }); - wrapper.update(); - assert.isFalse(wrapper.exists(childrenIdSelector)); - assert.strictEqual(onEntered.callCount, 0); // Ensure transition state was never "entered" + render() { + return ( +
+ + + + {children} + + +
+ ); + } + } + + const wrapper = mount(); + assert.strictEqual(wrapper.contains(children), false); + wrapper.find('button').simulate('click'); + assert.strictEqual(wrapper.contains(children), false); }); });