Skip to content

Commit

Permalink
Introduced 'static' key for muiTheme object.
Browse files Browse the repository at this point in the history
Fixed unit tests to use new theming code.
  • Loading branch information
Shaurya Arora authored and Shaurya Arora committed Sep 22, 2015
1 parent 75848a8 commit d9bfeb0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/styles/theme-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,12 @@ module.exports = {
returnObj.raisedButton.disabledTextColor = ColorManipulator.fade(returnObj.raisedButton.textColor, 0.3);
returnObj.toggle.trackRequiredColor = ColorManipulator.fade(returnObj.toggle.thumbRequiredColor, 0.5);

//finally, append the raw theme object to 'returnObj'
//append the raw theme object to 'returnObj'
returnObj.rawTheme = rawTheme;

//set 'static' key as true (by default) on return object. This is to support the ContextPure mixin.
returnObj.static = true;

return returnObj;
},

Expand Down
6 changes: 2 additions & 4 deletions test/fixtures/inject-theme.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import stubContext from 'react-stub-context';
import ThemeManager from 'styles/theme-manager';

const Manager = new ThemeManager();

import DefaultRawTheme from 'styles/raw-themes/light-raw-theme';

function injectTheme(Component, theme) {
let injectedTheme = theme || Manager.getCurrentTheme();
let injectedTheme = theme || ThemeManager.getMuiTheme(DefaultRawTheme);
return stubContext(Component, {muiTheme: injectedTheme});
}

Expand Down
5 changes: 3 additions & 2 deletions test/mixin-context-pure-spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react/addons';
import ContextPure from 'mixins/context-pure';
import ThemeManager from 'styles/theme-manager';
import DefaultRawTheme from 'styles/raw-themes/light-raw-theme';

const TestUtils = React.addons.TestUtils;
const update = React.addons.update;
Expand Down Expand Up @@ -98,7 +99,7 @@ const ParentComponent = React.createClass({

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

Expand All @@ -109,7 +110,7 @@ const ParentComponent = React.createClass({
},

componentWillMount() {
this.theme = new ThemeManager();
this.theme = ThemeManager.getMuiTheme(DefaultRawTheme);
this.theme.static = this.props.staticTheme;
this.theme.childThemeProp = 0;
this.theme.grandChildThemeProp = 0;
Expand Down

0 comments on commit d9bfeb0

Please sign in to comment.