Skip to content

Commit

Permalink
[styles] Add test for isMuiElement compat
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Dec 13, 2018
1 parent fc2be23 commit 1bdd4a0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/material-ui-styles/src/withStyles.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { assert } from 'chai';
import React from 'react';
import { Input } from '@material-ui/core';
import { isMuiElement } from '@material-ui/core/utils/reactHelpers';
import withStyles from './withStyles';

describe('withStyles', () => {
Expand All @@ -8,4 +11,13 @@ describe('withStyles', () => {
const TestWithStyles = withStyles({})(Test);
assert.strictEqual(TestWithStyles.someStatic, undefined);
});

it('hoists mui internals', () => {
assert.strictEqual(isMuiElement(<Input />, ['Input']), true);

// the imported Input is decorated with @material-ui/core/styles
const StyledInput = withStyles({})(Input);

assert.strictEqual(isMuiElement(<StyledInput />, ['Input']), true);
});
});
10 changes: 10 additions & 0 deletions packages/material-ui-styles/src/withTheme.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from 'react';
import { assert } from 'chai';
import { createMount } from '@material-ui/core/test-utils';
import { Input } from '@material-ui/core';
import { isMuiElement } from '@material-ui/core/utils/reactHelpers';
import PropTypes from 'prop-types';
import withTheme from './withTheme';
import ThemeProvider from './ThemeProvider';
Expand Down Expand Up @@ -41,4 +43,12 @@ describe('withTheme', () => {
const TestWithTheme = withTheme()(Test);
assert.strictEqual(TestWithTheme.someStatic, undefined);
});

it('hoists mui internals', () => {
assert.strictEqual(isMuiElement(<Input />, ['Input']), true);

const ThemedInput = withTheme()(Input);

assert.strictEqual(isMuiElement(<ThemedInput />, ['Input']), true);
});
});

0 comments on commit 1bdd4a0

Please sign in to comment.