From de60732a015886b00beccedbbac8f1cedfc5fbf0 Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Wed, 17 Jul 2019 12:01:44 +0200 Subject: [PATCH] breakdown the tests --- .../material-ui/src/Portal/Portal.test.js | 72 ++++++++++--------- 1 file changed, 40 insertions(+), 32 deletions(-) diff --git a/packages/material-ui/src/Portal/Portal.test.js b/packages/material-ui/src/Portal/Portal.test.js index 0f521663cf5e88..8334c7f7c7ac97 100644 --- a/packages/material-ui/src/Portal/Portal.test.js +++ b/packages/material-ui/src/Portal/Portal.test.js @@ -47,40 +47,48 @@ describe('', () => { }); }); - it('should have access to the mountNode', () => { - let wrapper; - let mountNode; - const refSpy1 = spy(); - wrapper = mount( - -

Foo

-
, - ); - wrapper.unmount(); - assert.deepEqual(refSpy1.args, [[document.body], [null]]); + describe('ref', () => { + it('should have access to the mountNode when disabledPortal={false}', () => { + const refSpy = spy(); + const wrapper = mount( + +

Foo

+
, + ); + assert.deepEqual(refSpy.args, [[document.body]]); + wrapper.unmount(); + assert.deepEqual(refSpy.args, [[document.body], [null]]); + }); - const refSpy2 = spy(); - wrapper = mount( - -

Foo

-
, - ); - mountNode = document.querySelector('.woofPortal'); - wrapper.unmount(); - assert.deepEqual(refSpy2.args, [[mountNode], [null]]); - - const refSpy3 = spy(); - wrapper = mount( - -

Foo

-
, - ); - mountNode = document.querySelector('.woofPortal'); - wrapper.setProps({ - disablePortal: false, + it('should have access to the mountNode when disabledPortal={true}', () => { + const refSpy = spy(); + const wrapper = mount( + +

Foo

+
, + ); + const mountNode = document.querySelector('.woofPortal'); + assert.deepEqual(refSpy.args, [[mountNode]]); + wrapper.unmount(); + assert.deepEqual(refSpy.args, [[mountNode], [null]]); + }); + + it('should have access to the mountNode when switching disabledPortal', () => { + const refSpy = spy(); + const wrapper = mount( + +

Foo

+
, + ); + const mountNode = document.querySelector('.woofPortal'); + assert.deepEqual(refSpy.args, [[mountNode]]); + wrapper.setProps({ + disablePortal: false, + }); + assert.deepEqual(refSpy.args, [[mountNode], [null], [document.body]]); + wrapper.unmount(); + assert.deepEqual(refSpy.args, [[mountNode], [null], [document.body], [null]]); }); - wrapper.unmount(); - assert.deepEqual(refSpy3.args, [[mountNode], [null], [document.body], [null]]); }); it('should render in a different node', () => {