Skip to content

Commit

Permalink
reverted more files under classic
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyan Zhang committed Jul 22, 2016
1 parent 43f55c8 commit de6bb6e
Show file tree
Hide file tree
Showing 4 changed files with 330 additions and 369 deletions.
132 changes: 66 additions & 66 deletions src/isomorphic/classic/__tests__/ReactContextValidator-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,33 +41,33 @@ describe('ReactContextValidator', function() {
// ensure that this is not required for ES6 classes with Flow.

it('should filter out context not in contextTypes', function() {
class Component extends React.Component {
static contextTypes = {
var Component = React.createClass({
contextTypes: {
foo: React.PropTypes.string,
};
},

render() {
render: function() {
return <div />;
}
}
},
});

class ComponentInFooBarContext extends React.Component {
static childContextTypes = {
var ComponentInFooBarContext = React.createClass({
childContextTypes: {
foo: React.PropTypes.string,
bar: React.PropTypes.number,
};
},

getChildContext() {
getChildContext: function() {
return {
foo: 'abc',
bar: 123,
};
}
},

render() {
render: function() {
return <Component />;
}
}
},
});

var instance = ReactTestUtils.renderIntoDocument(<ComponentInFooBarContext />);
reactComponentExpect(instance).expectRenderedChild().scalarContextEqual({foo: 'abc'});
Expand All @@ -79,51 +79,51 @@ describe('ReactContextValidator', function() {
var actualComponentWillUpdate;
var actualComponentDidUpdate;

class Parent extends React.Component {
static childContextTypes = {
var Parent = React.createClass({
childContextTypes: {
foo: React.PropTypes.string.isRequired,
bar: React.PropTypes.string.isRequired,
};
},

getChildContext() {
getChildContext: function() {
return {
foo: this.props.foo,
bar: 'bar',
};
}
},

render() {
render: function() {
return <Component />;
}
}
},
});

class Component extends React.Component {
static contextTypes = {
var Component = React.createClass({
contextTypes: {
foo: React.PropTypes.string,
};
},

componentWillReceiveProps(nextProps, nextContext) {
componentWillReceiveProps: function(nextProps, nextContext) {
actualComponentWillReceiveProps = nextContext;
return true;
}
},

shouldComponentUpdate(nextProps, nextState, nextContext) {
shouldComponentUpdate: function(nextProps, nextState, nextContext) {
actualShouldComponentUpdate = nextContext;
return true;
}
},

componentWillUpdate(nextProps, nextState, nextContext) {
componentWillUpdate: function(nextProps, nextState, nextContext) {
actualComponentWillUpdate = nextContext;
}
},

componentDidUpdate(prevProps, prevState, prevContext) {
componentDidUpdate: function(prevProps, prevState, prevContext) {
actualComponentDidUpdate = prevContext;
}
},

render() {
render: function() {
return <div />;
}
}
},
});

var container = document.createElement('div');
ReactDOM.render(<Parent foo="abc" />, container);
Expand All @@ -137,15 +137,15 @@ describe('ReactContextValidator', function() {
it('should check context types', function() {
spyOn(console, 'error');

class Component extends React.Component {
static contextTypes = {
var Component = React.createClass({
contextTypes: {
foo: React.PropTypes.string.isRequired,
};
},

render() {
render: function() {
return <div />;
}
}
},
});

ReactTestUtils.renderIntoDocument(<Component />);

Expand All @@ -156,21 +156,21 @@ describe('ReactContextValidator', function() {
' in Component (at **)'
);

class ComponentInFooStringContext extends React.Component {
static childContextTypes = {
var ComponentInFooStringContext = React.createClass({
childContextTypes: {
foo: React.PropTypes.string,
};
},

getChildContext() {
getChildContext: function() {
return {
foo: this.props.fooValue,
};
}
},

render() {
render: function() {
return <Component />;
}
}
},
});

ReactTestUtils.renderIntoDocument(
<ComponentInFooStringContext fooValue={'bar'} />
Expand All @@ -179,21 +179,21 @@ describe('ReactContextValidator', function() {
// Previous call should not error
expect(console.error.calls.count()).toBe(1);

class ComponentInFooNumberContext extends React.Component {
static childContextTypes = {
var ComponentInFooNumberContext = React.createClass({
childContextTypes: {
foo: React.PropTypes.number,
};
},

getChildContext() {
getChildContext: function() {
return {
foo: this.props.fooValue,
};
}
},

render() {
render: function() {
return <Component />;
}
}
},
});

ReactTestUtils.renderIntoDocument(<ComponentInFooNumberContext fooValue={123} />);

Expand All @@ -210,20 +210,20 @@ describe('ReactContextValidator', function() {
it('should check child context types', function() {
spyOn(console, 'error');

class Component extends React.Component {
static childContextTypes = {
var Component = React.createClass({
childContextTypes: {
foo: React.PropTypes.string.isRequired,
bar: React.PropTypes.number,
};
},

getChildContext() {
getChildContext: function() {
return this.props.testContext;
}
},

render() {
render: function() {
return <div />;
}
}
},
});

ReactTestUtils.renderIntoDocument(<Component testContext={{bar: 123}} />);
expect(console.error.calls.count()).toBe(1);
Expand Down
Loading

0 comments on commit de6bb6e

Please sign in to comment.