コード例 #1
0
  it('should work when we mutate the muiTheme', () => {
    const muiTheme1 = getMuiTheme({
      palette: {
        accent1Color: 'Colors.deepOrange500',
      },
      userAgent: 'all',
    });

    const muiTheme2 = getMuiTheme(muiTheme1, {
      palette: {
        accent1Color: 'Colors.deepOrange600',
      },
      appBar: {
        height: 56,
      },
    });

    expect(muiTheme2.userAgent).to.equal('all');
    expect(muiTheme2.palette.accent1Color).to.equal('Colors.deepOrange600');
    expect(muiTheme2.appBar.height).to.equal(56);
  });
コード例 #2
0
    it('should not prefix when userAgent is false', () => {
      const muiTheme = getMuiTheme({}, {
        userAgent: false,
      });

      const stylePrepared = muiTheme.prepareStyles({
        transform: 'rotate(90)',
      });

      expect(stylePrepared).to.deep.equal({
        transform: 'rotate(90)',
        muiPrepared: true,
      });
    });
コード例 #3
0
    it('should prefix for the userAgent when we provid a valid one', () => {
      const muiTheme = getMuiTheme({}, {
        userAgent: MSIE9_USER_AGENT,
      });

      const stylePrepared = muiTheme.prepareStyles({
        transform: 'rotate(90)',
      });

      expect(stylePrepared).to.deep.equal({
        muiPrepared: true,
        msTransform: 'rotate(90)',
      });
    });
コード例 #4
0
  it('should work when we use one parameter', () => {
    const muiTheme = getMuiTheme({
      palette: {
        accent1Color: 'Colors.deepOrange500',
      },
      userAgent: 'all',
      appBar: {
        height: 56,
      },
    });

    expect(muiTheme.userAgent).to.equal('all');
    expect(muiTheme.palette.accent1Color).to.equal('Colors.deepOrange500');
    expect(muiTheme.appBar.height).to.equal(56);
  });
コード例 #5
0
    it('should prefix for all when userAgent is all', () => {
      const muiTheme = getMuiTheme({}, {
        userAgent: 'all',
      });

      const stylePrepared = muiTheme.prepareStyles({
        transform: 'rotate(90)',
      });

      expect(stylePrepared).to.deep.equal({
        transform: 'rotate(90)',
        muiPrepared: true,
        WebkitTransform: 'rotate(90)',
        MozTransform: 'rotate(90)',
        msTransform: 'rotate(90)',
      });
    });
コード例 #6
0
describe('<RaisedButton />', () => {
  const muiTheme = getMuiTheme();
  const container = document.createElement('div');
  document.body.appendChild(container);
  const mountWithContext = (node) =>
    mount(node, {
      attachTo: container,
      context: {muiTheme},
    });

  it('renders a hover overlay of equal height to the button', () => {
    const wrappers = [
      () => mountWithContext(
        <RaisedButton>Hello World</RaisedButton>
      ),
      () => mountWithContext(
        <RaisedButton
          backgroundColor="#a4c639"
          icon={<ActionAndroid />}
        />
      ),
    ];

    wrappers.forEach((createWrapper) => {
      const wrapper = createWrapper();
      wrapper.simulate('mouseEnter');

      const overlay = wrapper.ref('overlay');
      const button = ReactDOM.findDOMNode(
        TestUtils.findRenderedDOMComponentWithTag(
          wrapper.instance(),
          'button'
        )
      );

      assert.strictEqual(
        overlay.node.clientHeight,
        button.clientHeight,
        'overlay height should match the button height'
      );
    });
  });
});
コード例 #7
0
      expect(appbarDiv.style.backgroundColor).to.equal('rgb(0, 188, 212)');
      expect(firstH1.style.color).to.equal('rgb(98, 0, 234)');
    });
  });
});

//react components used for context-theme-passing testing
const AppBarDarkUsingContext = React.createClass({

  childContextTypes: {
    muiTheme: React.PropTypes.object,
  },

  getChildContext() {
    return {
      muiTheme: getMuiTheme(darkBaseTheme),
    };
  },

  render() {
    return (<AppBar />);
  },
});

const AppBarDarkUsingContextWithOverride = React.createClass({

  childContextTypes: {
    muiTheme: React.PropTypes.object,
  },

  getInitialState() {
コード例 #8
0
  },

  getInitialState() {
    return {
      childProp: 0,
    };
  },

  getChildContext() {
    return {
      muiTheme: this.theme,
    };
  },

  componentWillMount() {
    this.theme = getMuiTheme();
    this.theme.static = this.props.staticTheme;
    this.theme.childThemeProp = 0;
    this.theme.grandChildThemeProp = 0;
  },

  renderCount: 0,

  getChildRenderCount() {
    return this.refs.child.getRenderCount();
  },

  getGrandChildRenderCount() {
    return this.refs.child.getGrandChildRenderCount();
  },