From 17c74cd698a93f32f905060dac390c4c7157c957 Mon Sep 17 00:00:00 2001 From: Kristen Mills Date: Sun, 15 Dec 2019 14:58:22 -0800 Subject: [PATCH 1/4] [Drawer] Append className from PaperProps instead of overwrite --- packages/material-ui/src/Drawer/Drawer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/material-ui/src/Drawer/Drawer.js b/packages/material-ui/src/Drawer/Drawer.js index 3421722f7f0b4f..1bd5ee5b1fc284 100644 --- a/packages/material-ui/src/Drawer/Drawer.js +++ b/packages/material-ui/src/Drawer/Drawer.js @@ -134,6 +134,7 @@ const Drawer = React.forwardRef(function Drawer(props, ref) { {children} From 0bfd51cd55baaf3350e8b1314e040c402df0e725 Mon Sep 17 00:00:00 2001 From: Kristen Mills Date: Sun, 15 Dec 2019 15:17:36 -0800 Subject: [PATCH 2/4] Add new tests --- .../material-ui/src/Drawer/Drawer.test.js | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/packages/material-ui/src/Drawer/Drawer.test.js b/packages/material-ui/src/Drawer/Drawer.test.js index c05c16bb5fa0ce..5dd8841b79a4fe 100644 --- a/packages/material-ui/src/Drawer/Drawer.test.js +++ b/packages/material-ui/src/Drawer/Drawer.test.js @@ -217,6 +217,29 @@ describe('', () => { }); }); + + describe('prop: PaperProps', () => { + const drawerElement = ( + +

Hello

+
+ ); + + it('should render paper with my-class', () => { + const wrapper = mount(drawerElement); + + const paper = wrapper.find(Paper); + assert.strictEqual(paper.hasClass('my-class'), true); + }); + + it('should render paper with classes.paper', () => { + const wrapper = mount(drawerElement); + + const paper = wrapper.find(Paper); + assert.strictEqual(paper.hasClass(classes.paper), true); + }); + }); + describe('slide direction', () => { it('should return the opposing slide direction', () => { const wrapper = mount( @@ -292,4 +315,5 @@ describe('', () => { assert.strictEqual(getAnchor(theme, 'right'), 'left'); }); }); + }); From 514ac88cc70b896bf48e5077a75999f31433033c Mon Sep 17 00:00:00 2001 From: Kristen Mills Date: Sun, 15 Dec 2019 15:19:28 -0800 Subject: [PATCH 3/4] prettier --- packages/material-ui/src/Drawer/Drawer.test.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/material-ui/src/Drawer/Drawer.test.js b/packages/material-ui/src/Drawer/Drawer.test.js index 5dd8841b79a4fe..e511e1cd86cbf5 100644 --- a/packages/material-ui/src/Drawer/Drawer.test.js +++ b/packages/material-ui/src/Drawer/Drawer.test.js @@ -217,7 +217,6 @@ describe('', () => { }); }); - describe('prop: PaperProps', () => { const drawerElement = ( @@ -315,5 +314,4 @@ describe('', () => { assert.strictEqual(getAnchor(theme, 'right'), 'left'); }); }); - }); From 35f968620bdf6f9f84066b85e6b32988380fc739 Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Mon, 16 Dec 2019 12:12:38 +0100 Subject: [PATCH 4/4] move away from enzyme --- .../material-ui/src/Drawer/Drawer.test.js | 29 +++++++------------ 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/packages/material-ui/src/Drawer/Drawer.test.js b/packages/material-ui/src/Drawer/Drawer.test.js index e511e1cd86cbf5..9b281357735114 100644 --- a/packages/material-ui/src/Drawer/Drawer.test.js +++ b/packages/material-ui/src/Drawer/Drawer.test.js @@ -1,5 +1,5 @@ import React from 'react'; -import { assert } from 'chai'; +import { assert, expect } from 'chai'; import { createMount, findOutermostIntrinsic, getClasses } from '@material-ui/core/test-utils'; import { ThemeProvider, createMuiTheme } from '@material-ui/core/styles'; import describeConformance from '../test-utils/describeConformance'; @@ -7,10 +7,12 @@ import Slide from '../Slide'; import Paper from '../Paper'; import Modal from '../Modal'; import Drawer, { getAnchor, isHorizontal } from './Drawer'; +import { createClientRender } from 'test/utils/createClientRender'; describe('', () => { let mount; let classes; + const render = createClientRender({ strict: false }); before(() => { // StrictModeViolation: uses Slide @@ -218,24 +220,13 @@ describe('', () => { }); describe('prop: PaperProps', () => { - const drawerElement = ( - -

Hello

-
- ); - - it('should render paper with my-class', () => { - const wrapper = mount(drawerElement); - - const paper = wrapper.find(Paper); - assert.strictEqual(paper.hasClass('my-class'), true); - }); - - it('should render paper with classes.paper', () => { - const wrapper = mount(drawerElement); - - const paper = wrapper.find(Paper); - assert.strictEqual(paper.hasClass(classes.paper), true); + it('should merge class names', () => { + const { container } = render( + +

Hello

+
, + ); + expect(container.querySelector(`.${classes.paper}`)).to.have.class('my-class'); }); });