Skip to content

Commit

Permalink
breakdown the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Jul 17, 2019
1 parent efb0aaa commit de60732
Showing 1 changed file with 40 additions and 32 deletions.
72 changes: 40 additions & 32 deletions packages/material-ui/src/Portal/Portal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,40 +47,48 @@ describe('<Portal />', () => {
});
});

it('should have access to the mountNode', () => {
let wrapper;
let mountNode;
const refSpy1 = spy();
wrapper = mount(
<Portal ref={refSpy1}>
<h1>Foo</h1>
</Portal>,
);
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(
<Portal ref={refSpy}>
<h1>Foo</h1>
</Portal>,
);
assert.deepEqual(refSpy.args, [[document.body]]);
wrapper.unmount();
assert.deepEqual(refSpy.args, [[document.body], [null]]);
});

const refSpy2 = spy();
wrapper = mount(
<Portal disablePortal ref={refSpy2}>
<h1 className="woofPortal">Foo</h1>
</Portal>,
);
mountNode = document.querySelector('.woofPortal');
wrapper.unmount();
assert.deepEqual(refSpy2.args, [[mountNode], [null]]);

const refSpy3 = spy();
wrapper = mount(
<Portal disablePortal ref={refSpy3}>
<h1 className="woofPortal">Foo</h1>
</Portal>,
);
mountNode = document.querySelector('.woofPortal');
wrapper.setProps({
disablePortal: false,
it('should have access to the mountNode when disabledPortal={true}', () => {
const refSpy = spy();
const wrapper = mount(
<Portal disablePortal ref={refSpy}>
<h1 className="woofPortal">Foo</h1>
</Portal>,
);
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(
<Portal disablePortal ref={refSpy}>
<h1 className="woofPortal">Foo</h1>
</Portal>,
);
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', () => {
Expand Down

0 comments on commit de60732

Please sign in to comment.