Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions packages/material-ui/src/Box/Box.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import * as React from 'react';
import { assert } from 'chai';
import { expect } from 'chai';
import { createClientRender } from 'test/utils/createClientRender';
import { createMount } from '@material-ui/core/test-utils';
import describeConformance from '@material-ui/core/test-utils/describeConformance';
import Box from './Box';

describe('<Box />', () => {
let mount;

const render = createClientRender();
before(() => {
mount = createMount({ strict: true });
});
Expand All @@ -21,22 +22,25 @@ describe('<Box />', () => {
refInstanceof: window.HTMLDivElement,
}));

const testChildren = <div className="unique">Hello World</div>;
const testChildren = (
<div data-testid="child" className="unique">
Hello World
</div>
);

it('renders children and box content', () => {
const wrapper = mount(
const { container, getByTestId } = render(
<Box component="span" m={1}>
{testChildren}
</Box>,
);

assert.strictEqual(wrapper.contains(testChildren), true);
assert.strictEqual(wrapper.find('span').length, 1);
expect(container.firstChild).contain(getByTestId('child'));
expect(container.querySelectorAll('span').length).to.equal(1);
});

it('does not forward style props as DOM attributes', () => {
const elementRef = React.createRef();
mount(
render(
<Box
color="primary.main"
fontFamily="Comic Sans"
Expand All @@ -46,8 +50,8 @@ describe('<Box />', () => {
);

const { current: element } = elementRef;
assert.strictEqual(element.getAttribute('color'), null);
assert.strictEqual(element.getAttribute('font-family'), null);
assert.strictEqual(element.getAttribute('font-size'), null);
expect(element.getAttribute('color')).to.equal(null);
expect(element.getAttribute('font-family')).to.equal(null);
expect(element.getAttribute('font-size')).to.equal(null);
});
});