mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
lint: remove spaces from object braces
This commit is contained in:
@@ -29,7 +29,7 @@ var LICENSE_TEMPLATE =
|
||||
*/';
|
||||
|
||||
function minify(src) {
|
||||
return UglifyJS.minify(src, { fromString: true }).code;
|
||||
return UglifyJS.minify(src, {fromString: true}).code;
|
||||
}
|
||||
|
||||
// TODO: move this out to another build step maybe.
|
||||
|
||||
@@ -23,7 +23,7 @@ module.exports = function(props) {
|
||||
|
||||
exports.local = {
|
||||
webdriver: {
|
||||
remote: { protocol: 'http:', hostname: '127.0.0.1', port: 9515, path: '/' }
|
||||
remote: {protocol: 'http:', hostname: '127.0.0.1', port: 9515, path: '/'}
|
||||
},
|
||||
url: props.url,
|
||||
onStart: props.onStart,
|
||||
@@ -68,33 +68,33 @@ module.exports = function(props) {
|
||||
/*eslint-disable camelcase*/
|
||||
/* https://saucelabs.com/platforms */
|
||||
exports.saucelabs_ios =
|
||||
exports.saucelabs_ios7 = sauceItUp({ browserName: 'iphone', version: '7', platform:'OS X 10.9' });
|
||||
exports.saucelabs_ios6_1 = sauceItUp({ browserName: 'iphone', version: '6.1', platform:'OS X 10.8' });
|
||||
exports.saucelabs_ios6 = sauceItUp({ browserName: 'iphone', version: '6', platform:'OS X 10.8' });
|
||||
exports.saucelabs_ios5_1 = sauceItUp({ browserName: 'iphone', version: '5.1', platform:'OS X 10.8' });
|
||||
exports.saucelabs_ios5 = sauceItUp({ browserName: 'iphone', version: '5', platform:'OS X 10.6' });
|
||||
exports.saucelabs_ios4 = sauceItUp({ browserName: 'iphone', version: '4', platform:'OS X 10.6' });
|
||||
exports.saucelabs_ios7 = sauceItUp({browserName: 'iphone', version: '7', platform:'OS X 10.9'});
|
||||
exports.saucelabs_ios6_1 = sauceItUp({browserName: 'iphone', version: '6.1', platform:'OS X 10.8'});
|
||||
exports.saucelabs_ios6 = sauceItUp({browserName: 'iphone', version: '6', platform:'OS X 10.8'});
|
||||
exports.saucelabs_ios5_1 = sauceItUp({browserName: 'iphone', version: '5.1', platform:'OS X 10.8'});
|
||||
exports.saucelabs_ios5 = sauceItUp({browserName: 'iphone', version: '5', platform:'OS X 10.6'});
|
||||
exports.saucelabs_ios4 = sauceItUp({browserName: 'iphone', version: '4', platform:'OS X 10.6'});
|
||||
|
||||
exports.saucelabs_ipad =
|
||||
exports.saucelabs_ipad7 = sauceItUp({ browserName: 'ipad', version: '7', platform:'OS X 10.9' });
|
||||
exports.saucelabs_ipad6_1 = sauceItUp({ browserName: 'ipad', version: '6.1', platform:'OS X 10.8' });
|
||||
exports.saucelabs_ipad6 = sauceItUp({ browserName: 'ipad', version: '6', platform:'OS X 10.8' });
|
||||
exports.saucelabs_ipad5_1 = sauceItUp({ browserName: 'ipad', version: '5.1', platform:'OS X 10.8' });
|
||||
exports.saucelabs_ipad5 = sauceItUp({ browserName: 'ipad', version: '5', platform:'OS X 10.6' });
|
||||
exports.saucelabs_ipad4 = sauceItUp({ browserName: 'ipad', version: '4', platform:'OS X 10.6' });
|
||||
exports.saucelabs_ipad7 = sauceItUp({browserName: 'ipad', version: '7', platform:'OS X 10.9'});
|
||||
exports.saucelabs_ipad6_1 = sauceItUp({browserName: 'ipad', version: '6.1', platform:'OS X 10.8'});
|
||||
exports.saucelabs_ipad6 = sauceItUp({browserName: 'ipad', version: '6', platform:'OS X 10.8'});
|
||||
exports.saucelabs_ipad5_1 = sauceItUp({browserName: 'ipad', version: '5.1', platform:'OS X 10.8'});
|
||||
exports.saucelabs_ipad5 = sauceItUp({browserName: 'ipad', version: '5', platform:'OS X 10.6'});
|
||||
exports.saucelabs_ipad4 = sauceItUp({browserName: 'ipad', version: '4', platform:'OS X 10.6'});
|
||||
|
||||
exports.saucelabs_android = sauceItUp({ browserName: 'android', version: '4.0', platform:'Linux' });
|
||||
exports.saucelabs_android_tablet = sauceItUp({ browserName: 'android', version: '4.0', platform:'Linux', 'device-type':'tablet' });
|
||||
exports.saucelabs_android = sauceItUp({browserName: 'android', version: '4.0', platform:'Linux'});
|
||||
exports.saucelabs_android_tablet = sauceItUp({browserName: 'android', version: '4.0', platform:'Linux', 'device-type':'tablet'});
|
||||
|
||||
exports.saucelabs_safari = sauceItUp({ browserName: 'safari' });
|
||||
exports.saucelabs_chrome = sauceItUp({ browserName: 'chrome' });
|
||||
exports.saucelabs_firefox = sauceItUp({ browserName: 'firefox' });
|
||||
exports.saucelabs_safari = sauceItUp({browserName: 'safari'});
|
||||
exports.saucelabs_chrome = sauceItUp({browserName: 'chrome'});
|
||||
exports.saucelabs_firefox = sauceItUp({browserName: 'firefox'});
|
||||
|
||||
exports.saucelabs_ie =
|
||||
exports.saucelabs_ie8 = sauceItUp({ browserName: 'internet explorer', version: 8 });
|
||||
exports.saucelabs_ie9 = sauceItUp({ browserName: 'internet explorer', version: 9 });
|
||||
exports.saucelabs_ie10 = sauceItUp({ browserName: 'internet explorer', version: 10 });
|
||||
exports.saucelabs_ie11 = sauceItUp({ browserName: 'internet explorer', version: 11, platform:'Windows 8.1' });
|
||||
exports.saucelabs_ie8 = sauceItUp({browserName: 'internet explorer', version: 8});
|
||||
exports.saucelabs_ie9 = sauceItUp({browserName: 'internet explorer', version: 9});
|
||||
exports.saucelabs_ie10 = sauceItUp({browserName: 'internet explorer', version: 10});
|
||||
exports.saucelabs_ie11 = sauceItUp({browserName: 'internet explorer', version: 11, platform:'Windows 8.1'});
|
||||
/*eslint-enable camelcase*/
|
||||
|
||||
function sauceItUp(desiredCapabilities) {
|
||||
|
||||
+2
-2
@@ -59,7 +59,7 @@ module.exports = function() {
|
||||
'install',
|
||||
'--production',
|
||||
tgz
|
||||
], { cwd: dir }, function() {
|
||||
], {cwd: dir}, function() {
|
||||
var nodePath = path.join(dir, 'node_modules');
|
||||
var pkgDir = path.join(nodePath, pkg.name);
|
||||
var doneCount = 2;
|
||||
@@ -83,7 +83,7 @@ module.exports = function() {
|
||||
'/** @jsx React.DOM */ <div>oyez</div>;'
|
||||
) + ')'
|
||||
], {
|
||||
env: { NODE_PATH: nodePath }
|
||||
env: {NODE_PATH: nodePath}
|
||||
}, function(result, code) {
|
||||
assert.ok(result.stdout.indexOf(
|
||||
'React.DOM.div(null, \'oyez\');'
|
||||
|
||||
@@ -30,7 +30,7 @@ function _gitCommitAndTag(cwd, commitMsg, tag, cb) {
|
||||
// `git add -u` to make sure we remove deleted files
|
||||
// `git commit -m {commitMsg}`
|
||||
// `git tag -a {tag}`
|
||||
var opts = { cwd: cwd};
|
||||
var opts = {cwd: cwd};
|
||||
var gitAddAll = {
|
||||
cmd: 'git',
|
||||
args: ['add', '*'],
|
||||
@@ -91,7 +91,7 @@ function bower() {
|
||||
// clean out the bower folder in case we're removing files
|
||||
var files = grunt.file.expand(BOWER_GLOB);
|
||||
files.forEach(function(file) {
|
||||
grunt.file.delete(file, { force: true });
|
||||
grunt.file.delete(file, {force: true});
|
||||
});
|
||||
|
||||
// Update bower package version and save the file back.
|
||||
@@ -113,7 +113,7 @@ function docs() {
|
||||
|
||||
var files = grunt.file.expand(GH_PAGES_GLOB);
|
||||
files.forEach(function(file) {
|
||||
grunt.file.delete(file, { force: true });
|
||||
grunt.file.delete(file, {force: true});
|
||||
});
|
||||
|
||||
grunt.file.copy('build/react-' + VERSION + '.zip', 'docs/downloads/react-' + VERSION + '.zip');
|
||||
@@ -123,7 +123,7 @@ function docs() {
|
||||
var rakeOpts = {
|
||||
cmd: 'rake',
|
||||
args: ['release'],
|
||||
opts: { cwd: 'docs' }
|
||||
opts: {cwd: 'docs'}
|
||||
};
|
||||
grunt.util.spawn(rakeOpts, function() {
|
||||
// Commit the repo. We don't really care about tagging this.
|
||||
|
||||
@@ -4,7 +4,7 @@ var fs = require('fs');
|
||||
var path = require('path');
|
||||
var ts = require('typescript');
|
||||
|
||||
var tsOptions = { module: 'commonjs' };
|
||||
var tsOptions = {module: 'commonjs'};
|
||||
|
||||
function formatErrorMessage(error) {
|
||||
return (
|
||||
|
||||
@@ -164,7 +164,7 @@ BrowserPerfRunnerApp.renderBenchmarkCell = function(props, row, col) {
|
||||
return (
|
||||
React.DOM.td({key:key, style:{textAlign:'center', width:234, verticalAlign:'top'}},
|
||||
benchmark.error && benchmark.error.message || '',
|
||||
React.DOM.div({style: benchmark.isTheWinner ? { backgroundColor:'#0A5', color:'#AFA' } : {backgroundColor:'transparent', color:'inherit'}},
|
||||
React.DOM.div({style: benchmark.isTheWinner ? {backgroundColor:'#0A5', color:'#AFA'} : {backgroundColor:'transparent', color:'inherit'}},
|
||||
Math.round(1 / benchmark.stats.mean * 100) / 100, ' op/s ',
|
||||
React.DOM.strong(null, Math.round(benchmark.stats.mean * 1000 * 100) / 100, ' ms/op '),
|
||||
React.DOM.small(null, '(±' + (Math.round(benchmark.stats.rme * 10) / 10) + '%)')
|
||||
@@ -198,7 +198,7 @@ var GridViewTable = React.createClass({
|
||||
},
|
||||
|
||||
_renderCell: function(col) {
|
||||
return this.props.renderCell({ value:this.props.value }, this._row, col);
|
||||
return this.props.renderCell({value:this.props.value}, this._row, col);
|
||||
},
|
||||
|
||||
_renderRow: function(row) {
|
||||
|
||||
@@ -62,7 +62,7 @@ var BenchmarkQueue = React.createClass({
|
||||
if (self.props.onCompleteEach) {
|
||||
self.props.onCompleteEach(queueItem);
|
||||
}
|
||||
self.setState({ queue:queue });
|
||||
self.setState({queue:queue});
|
||||
});
|
||||
benchmark.run({async:true});
|
||||
},
|
||||
|
||||
@@ -50,7 +50,7 @@ todolist.App = React.createClass({
|
||||
if (callback) {
|
||||
callback = callback.bind(this, todo);
|
||||
}
|
||||
this.setState({ timerEvent:'addItem', timerStart:todolist.now(), timerEnd:null, todos:todos }, callback);
|
||||
this.setState({timerEvent:'addItem', timerStart:todolist.now(), timerEnd:null, todos:todos}, callback);
|
||||
return todo;
|
||||
},
|
||||
deleteItemById: function(id, callback) {
|
||||
@@ -59,7 +59,7 @@ todolist.App = React.createClass({
|
||||
return callback && callback(Error('todo with id ' + id + ' not found'));
|
||||
}
|
||||
todo.deleted = true;
|
||||
this.setState({ timerEvent:'deleteItemById', timerStart:todolist.now(), timerEnd:null, todos:this.state.todos }, callback);
|
||||
this.setState({timerEvent:'deleteItemById', timerStart:todolist.now(), timerEnd:null, todos:this.state.todos}, callback);
|
||||
},
|
||||
setItemCompleted: function(id, completed, callback) {
|
||||
var todo = this._getById(id);
|
||||
@@ -67,7 +67,7 @@ todolist.App = React.createClass({
|
||||
return callback && callback(Error('todo with id ' + id + ' not found'));
|
||||
}
|
||||
todo.completed = completed;
|
||||
this.setState({ timerEvent:'setItemCompleted', timerStart:todolist.now(), timerEnd:null, todos:this.state.todos }, callback);
|
||||
this.setState({timerEvent:'setItemCompleted', timerStart:todolist.now(), timerEnd:null, todos:this.state.todos}, callback);
|
||||
},
|
||||
_getById: function(id) {
|
||||
id = +id;
|
||||
|
||||
@@ -15,7 +15,7 @@ exports.setup = function() {
|
||||
|
||||
var AwesomeComponent = React.createClass({
|
||||
getInitialState: function() {
|
||||
return { random:null };
|
||||
return {random:null};
|
||||
},
|
||||
render: function() {
|
||||
if (!setState) {
|
||||
|
||||
@@ -15,7 +15,7 @@ exports.setup = function() {
|
||||
|
||||
var AwesomeComponent = React.createClass({
|
||||
getInitialState: function() {
|
||||
return { random:null };
|
||||
return {random:null};
|
||||
},
|
||||
render: function() {
|
||||
if (!setState) {
|
||||
|
||||
@@ -11,7 +11,7 @@ exports.defer = true;
|
||||
exports.setup = function() {
|
||||
_rootNode = document.createElement('div');
|
||||
document.body.appendChild(_rootNode);
|
||||
var appDescriptor = todolist.App({ fakeDataCount: 333 });
|
||||
var appDescriptor = todolist.App({fakeDataCount: 333});
|
||||
_app = React.render(appDescriptor, _rootNode);
|
||||
};
|
||||
exports.fn = function(deferred) {
|
||||
|
||||
@@ -13,7 +13,7 @@ exports.defer = true;
|
||||
exports.setup = function() {
|
||||
_rootNode = document.createElement('div');
|
||||
document.body.appendChild(_rootNode);
|
||||
var appDescriptor = todolist.App({ fakeDataCount: 333 });
|
||||
var appDescriptor = todolist.App({fakeDataCount: 333});
|
||||
_app = React.render(appDescriptor, _rootNode);
|
||||
};
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ exports.defer = true;
|
||||
exports.setup = function() {
|
||||
_rootNode = document.createElement('div');
|
||||
document.body.appendChild(_rootNode);
|
||||
var appDescriptor = todolist.App({ fakeDataCount: 333 });
|
||||
var appDescriptor = todolist.App({fakeDataCount: 333});
|
||||
_app = React.render(appDescriptor, _rootNode);
|
||||
_todo1 = _app.addItem('Howdy 1!');
|
||||
_todo2 = _app.addItem('Howdy 2!');
|
||||
|
||||
@@ -18,7 +18,7 @@ exports.setup = function() {
|
||||
};
|
||||
|
||||
exports.fn = function(deferred) {
|
||||
React.render(todolist.App({ fakeDataCount: 333 }), _rootNode, function() {
|
||||
React.render(todolist.App({fakeDataCount: 333}), _rootNode, function() {
|
||||
deferred.resolve();
|
||||
});
|
||||
};
|
||||
|
||||
@@ -39,13 +39,13 @@ if (__DEV__) {
|
||||
Object.defineProperty(
|
||||
{},
|
||||
fragmentKey,
|
||||
{ enumerable: false, value: true }
|
||||
{enumerable: false, value: true}
|
||||
);
|
||||
|
||||
Object.defineProperty(
|
||||
{},
|
||||
'key',
|
||||
{ enumerable: true, get: dummy }
|
||||
{enumerable: true, get: dummy}
|
||||
);
|
||||
|
||||
canWarnForReactFragment = true;
|
||||
|
||||
@@ -48,7 +48,7 @@ describe('ReactDOM', function() {
|
||||
*/
|
||||
|
||||
it("allows a DOM element to be used with a string", function() {
|
||||
var element = React.createElement('div', { className: 'foo' });
|
||||
var element = React.createElement('div', {className: 'foo'});
|
||||
var instance = ReactTestUtils.renderIntoDocument(element);
|
||||
expect(instance.getDOMNode().tagName).toBe('DIV');
|
||||
});
|
||||
|
||||
@@ -45,14 +45,14 @@ describe('ReactDOMComponent', function() {
|
||||
var stubStyle = container.firstChild.style;
|
||||
|
||||
// set initial style
|
||||
var setup = { display: 'block', left: '1', top: 2, fontFamily: 'Arial' };
|
||||
var setup = {display: 'block', left: '1', top: 2, fontFamily: 'Arial'};
|
||||
React.render(<div style={setup} />, container);
|
||||
expect(stubStyle.display).toEqual('block');
|
||||
expect(stubStyle.left).toEqual('1px');
|
||||
expect(stubStyle.fontFamily).toEqual('Arial');
|
||||
|
||||
// reset the style to their default state
|
||||
var reset = { display: '', left: null, top: false, fontFamily: true };
|
||||
var reset = {display: '', left: null, top: false, fontFamily: true};
|
||||
React.render(<div style={reset} />, container);
|
||||
expect(stubStyle.display).toEqual('');
|
||||
expect(stubStyle.left).toEqual('');
|
||||
@@ -61,7 +61,7 @@ describe('ReactDOMComponent', function() {
|
||||
});
|
||||
|
||||
it("should update styles when mutating style object", function() {
|
||||
var styles = { display: 'none', fontFamily: 'Arial', lineHeight: 1.2 };
|
||||
var styles = {display: 'none', fontFamily: 'Arial', lineHeight: 1.2};
|
||||
var container = document.createElement('div');
|
||||
React.render(<div style={styles} />, container);
|
||||
|
||||
@@ -226,7 +226,7 @@ describe('ReactDOMComponent', function() {
|
||||
var ReactReconcileTransaction = require('ReactReconcileTransaction');
|
||||
|
||||
var NodeStub = function(initialProps) {
|
||||
this._currentElement = { props: initialProps };
|
||||
this._currentElement = {props: initialProps};
|
||||
this._rootNodeID = 'test';
|
||||
};
|
||||
assign(NodeStub.prototype, ReactDOMComponent.Mixin);
|
||||
@@ -250,9 +250,9 @@ describe('ReactDOMComponent', function() {
|
||||
});
|
||||
|
||||
it("should generate the correct markup with className", function() {
|
||||
expect(genMarkup({ className: 'a' })).toHaveAttribute('class', 'a');
|
||||
expect(genMarkup({ className: 'a b' })).toHaveAttribute('class', 'a b');
|
||||
expect(genMarkup({ className: '' })).toHaveAttribute('class', '');
|
||||
expect(genMarkup({className: 'a'})).toHaveAttribute('class', 'a');
|
||||
expect(genMarkup({className: 'a b'})).toHaveAttribute('class', 'a b');
|
||||
expect(genMarkup({className: ''})).toHaveAttribute('class', '');
|
||||
});
|
||||
|
||||
it("should escape style names and values", function() {
|
||||
@@ -276,7 +276,7 @@ describe('ReactDOMComponent', function() {
|
||||
var ReactReconcileTransaction = require('ReactReconcileTransaction');
|
||||
|
||||
var NodeStub = function(initialProps) {
|
||||
this._currentElement = { props: initialProps };
|
||||
this._currentElement = {props: initialProps};
|
||||
this._rootNodeID = 'test';
|
||||
};
|
||||
assign(NodeStub.prototype, ReactDOMComponent.Mixin);
|
||||
@@ -297,7 +297,7 @@ describe('ReactDOMComponent', function() {
|
||||
it("should handle dangerouslySetInnerHTML", function() {
|
||||
var innerHTML = {__html: 'testContent'};
|
||||
expect(
|
||||
genMarkup({ dangerouslySetInnerHTML: innerHTML })
|
||||
genMarkup({dangerouslySetInnerHTML: innerHTML})
|
||||
).toHaveInnerhtml('testContent');
|
||||
});
|
||||
});
|
||||
@@ -332,7 +332,7 @@ describe('ReactDOMComponent', function() {
|
||||
|
||||
it("should validate against multiple children props", function() {
|
||||
expect(function() {
|
||||
mountComponent({ children: '', dangerouslySetInnerHTML: '' });
|
||||
mountComponent({children: '', dangerouslySetInnerHTML: ''});
|
||||
}).toThrow(
|
||||
'Invariant Violation: Can only set one of `children` or ' +
|
||||
'`props.dangerouslySetInnerHTML`.'
|
||||
@@ -342,7 +342,7 @@ describe('ReactDOMComponent', function() {
|
||||
it('should validate against use of innerHTML', function() {
|
||||
|
||||
spyOn(console, 'warn');
|
||||
mountComponent({ innerHTML: '<span>Hi Jim!</span>' });
|
||||
mountComponent({innerHTML: '<span>Hi Jim!</span>'});
|
||||
expect(console.warn.argsForCall.length).toBe(1);
|
||||
expect(console.warn.argsForCall[0][0]).toContain(
|
||||
'Directly setting property `innerHTML` is not permitted. '
|
||||
@@ -351,7 +351,7 @@ describe('ReactDOMComponent', function() {
|
||||
|
||||
it('should validate use of dangerouslySetInnerHTML', function() {
|
||||
expect(function() {
|
||||
mountComponent({ dangerouslySetInnerHTML: '<span>Hi Jim!</span>' });
|
||||
mountComponent({dangerouslySetInnerHTML: '<span>Hi Jim!</span>'});
|
||||
}).toThrow(
|
||||
'Invariant Violation: ' +
|
||||
'`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. ' +
|
||||
@@ -361,7 +361,7 @@ describe('ReactDOMComponent', function() {
|
||||
|
||||
it('should validate use of dangerouslySetInnerHTML', function() {
|
||||
expect(function() {
|
||||
mountComponent({ dangerouslySetInnerHTML: {foo: 'bar'} });
|
||||
mountComponent({dangerouslySetInnerHTML: {foo: 'bar'} });
|
||||
}).toThrow(
|
||||
'Invariant Violation: ' +
|
||||
'`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. ' +
|
||||
@@ -371,14 +371,14 @@ describe('ReactDOMComponent', function() {
|
||||
|
||||
it("should warn about contentEditable and children", function() {
|
||||
spyOn(console, 'warn');
|
||||
mountComponent({ contentEditable: true, children: '' });
|
||||
mountComponent({contentEditable: true, children: ''});
|
||||
expect(console.warn.argsForCall.length).toBe(1);
|
||||
expect(console.warn.argsForCall[0][0]).toContain('contentEditable');
|
||||
});
|
||||
|
||||
it("should validate against invalid styles", function() {
|
||||
expect(function() {
|
||||
mountComponent({ style: 'display: none' });
|
||||
mountComponent({style: 'display: none'});
|
||||
}).toThrow(
|
||||
'Invariant Violation: The `style` prop expects a mapping from style ' +
|
||||
'properties to values, not a string. For example, ' +
|
||||
|
||||
@@ -149,10 +149,10 @@ describe('autobinding', function() {
|
||||
|
||||
var TestBindComponent = React.createClass({
|
||||
getInitialState: function() {
|
||||
return { foo: 1 };
|
||||
return {foo: 1};
|
||||
},
|
||||
componentDidMount: function() {
|
||||
this.setState({ foo: 2 }, this.handleUpdate);
|
||||
this.setState({foo: 2}, this.handleUpdate);
|
||||
},
|
||||
handleUpdate: function() {
|
||||
|
||||
|
||||
@@ -305,7 +305,7 @@ describe('ReactClass-spec', function() {
|
||||
className: React.PropTypes.string
|
||||
},
|
||||
getInitialState() {
|
||||
return { className: this.context.className };
|
||||
return {className: this.context.className};
|
||||
},
|
||||
render() {
|
||||
return <span className={this.state.className} />;
|
||||
@@ -317,7 +317,7 @@ describe('ReactClass-spec', function() {
|
||||
className: React.PropTypes.string
|
||||
},
|
||||
getChildContext() {
|
||||
return { className: 'foo' };
|
||||
return {className: 'foo'};
|
||||
},
|
||||
render() {
|
||||
return <Foo />;
|
||||
|
||||
@@ -108,7 +108,7 @@ var ReactElement = function(type, key, ref, owner, context, props) {
|
||||
// an external backing store so that we can freeze the whole object.
|
||||
// This can be replaced with a WeakMap once they are implemented in
|
||||
// commonly used development environments.
|
||||
this._store = { props: props, originalProps: assign({}, props) };
|
||||
this._store = {props: props, originalProps: assign({}, props)};
|
||||
|
||||
// To make comparing ReactElements easier for testing purposes, we make
|
||||
// the validation flag non-enumerable (where possible, which should
|
||||
|
||||
@@ -56,7 +56,7 @@ describe('ReactElement', function() {
|
||||
});
|
||||
|
||||
it('does not reuse the original config object', function() {
|
||||
var config = { foo: 1 };
|
||||
var config = {foo: 1};
|
||||
var element = React.createFactory(ComponentClass)(config);
|
||||
expect(element.props.foo).toBe(1);
|
||||
config.foo = 2;
|
||||
@@ -95,7 +95,7 @@ describe('ReactElement', function() {
|
||||
foo: React.PropTypes.string
|
||||
},
|
||||
getChildContext: function() {
|
||||
return { foo: 'bar' };
|
||||
return {foo: 'bar'};
|
||||
},
|
||||
render: function() {
|
||||
element = Component();
|
||||
@@ -107,7 +107,7 @@ describe('ReactElement', function() {
|
||||
React.createElement(Wrapper)
|
||||
);
|
||||
|
||||
expect(element._context).toEqual({ foo: 'bar' });
|
||||
expect(element._context).toEqual({foo: 'bar'});
|
||||
});
|
||||
|
||||
it('preserves the owner on the element', function() {
|
||||
@@ -222,7 +222,7 @@ describe('ReactElement', function() {
|
||||
});
|
||||
|
||||
it('is indistinguishable from a plain object', function() {
|
||||
var element = React.createElement('div', { className: 'foo' });
|
||||
var element = React.createElement('div', {className: 'foo'});
|
||||
var object = {};
|
||||
expect(element.constructor).toBe(object.constructor);
|
||||
});
|
||||
@@ -239,7 +239,7 @@ describe('ReactElement', function() {
|
||||
|
||||
var container = document.createElement('div');
|
||||
var instance = React.render(
|
||||
React.createElement(Component, { fruit: 'mango' }),
|
||||
React.createElement(Component, {fruit: 'mango'}),
|
||||
container
|
||||
);
|
||||
expect(instance.props.fruit).toBe('mango');
|
||||
@@ -264,7 +264,7 @@ describe('ReactElement', function() {
|
||||
expect(instance.props.prop).toBe('testKey');
|
||||
|
||||
var inst2 = ReactTestUtils.renderIntoDocument(
|
||||
React.createElement(Component, { prop: null })
|
||||
React.createElement(Component, {prop: null})
|
||||
);
|
||||
expect(inst2.props.prop).toBe(null);
|
||||
});
|
||||
|
||||
@@ -64,7 +64,7 @@ describe('ReactElementValidator', function() {
|
||||
var ComponentWrapper = React.createClass({
|
||||
displayName: 'ComponentWrapper',
|
||||
render: function() {
|
||||
return InnerComponent({ childSet: [ Component(), Component() ] });
|
||||
return InnerComponent({childSet: [ Component(), Component() ] });
|
||||
}
|
||||
});
|
||||
|
||||
@@ -90,7 +90,7 @@ describe('ReactElementValidator', function() {
|
||||
return {
|
||||
next: function() {
|
||||
var done = ++i > 2;
|
||||
return { value: done ? undefined : Component(), done: done };
|
||||
return {value: done ? undefined : Component(), done: done};
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -141,7 +141,7 @@ describe('ReactElementValidator', function() {
|
||||
spyOn(console, 'warn');
|
||||
var Component = React.createFactory(ComponentClass);
|
||||
|
||||
Component(null, frag({ 1: Component(), 2: Component() }));
|
||||
Component(null, frag({1: Component(), 2: Component()}));
|
||||
|
||||
expect(console.warn.argsForCall.length).toBe(1);
|
||||
expect(console.warn.argsForCall[0][0]).toContain(
|
||||
@@ -159,7 +159,7 @@ describe('ReactElementValidator', function() {
|
||||
return {
|
||||
next: function() {
|
||||
var done = ++i > 2;
|
||||
return { value: done ? undefined : [i, Component()], done: done };
|
||||
return {value: done ? undefined : [i, Component()], done: done};
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -207,7 +207,7 @@ describe('ReactElementValidator', function() {
|
||||
});
|
||||
var ParentComp = React.createClass({
|
||||
render: function() {
|
||||
return React.createElement(MyComp, { color: 123 });
|
||||
return React.createElement(MyComp, {color: 123});
|
||||
}
|
||||
});
|
||||
ReactTestUtils.renderIntoDocument(React.createElement(ParentComp));
|
||||
@@ -325,7 +325,7 @@ describe('ReactElementValidator', function() {
|
||||
it('should warn if a fragment is used without the wrapper', function() {
|
||||
spyOn(console, 'warn');
|
||||
var child = React.createElement('span');
|
||||
React.createElement('div', null, { a: child, b: child });
|
||||
React.createElement('div', null, {a: child, b: child});
|
||||
expect(console.warn.calls.length).toBe(1);
|
||||
expect(console.warn.calls[0].args[0]).toContain('use of a keyed object');
|
||||
});
|
||||
|
||||
@@ -138,7 +138,7 @@ describe('ReactComponentLifeCycle', function() {
|
||||
var container = document.createElement('div');
|
||||
var StatefulComponent = React.createClass({
|
||||
getInitialState: function() {
|
||||
return { };
|
||||
return {};
|
||||
},
|
||||
render: function() {
|
||||
return (
|
||||
|
||||
@@ -303,7 +303,7 @@ describe('ReactCompositeComponent', function() {
|
||||
|
||||
var Component = React.createClass({
|
||||
getInitialState: function() {
|
||||
return { value: 0 };
|
||||
return {value: 0};
|
||||
},
|
||||
render: function() {
|
||||
return <div />;
|
||||
@@ -314,12 +314,12 @@ describe('ReactCompositeComponent', function() {
|
||||
expect(instance.setState).not.toBeDefined();
|
||||
|
||||
instance = React.render(instance, container);
|
||||
instance.setState({ value: 1 });
|
||||
instance.setState({value: 1});
|
||||
|
||||
expect(console.warn.calls.length).toBe(0);
|
||||
|
||||
React.unmountComponentAtNode(container);
|
||||
instance.setState({ value: 2 });
|
||||
instance.setState({value: 2});
|
||||
expect(console.warn.calls.length).toBe(1);
|
||||
expect(console.warn.argsForCall[0][0]).toBe(
|
||||
'Warning: setState(...): Can only update a mounted or ' +
|
||||
@@ -336,11 +336,11 @@ describe('ReactCompositeComponent', function() {
|
||||
|
||||
var Component = React.createClass({
|
||||
getInitialState: function() {
|
||||
return { value: 0 };
|
||||
return {value: 0};
|
||||
},
|
||||
componentWillUnmount: function() {
|
||||
expect(() => {
|
||||
this.setState({ value: 2 }, function() {
|
||||
this.setState({value: 2}, function() {
|
||||
cbCalled = true;
|
||||
})
|
||||
}).not.toThrow();
|
||||
@@ -352,7 +352,7 @@ describe('ReactCompositeComponent', function() {
|
||||
|
||||
var instance = React.render(<Component />, container);
|
||||
|
||||
instance.setState({ value: 1 });
|
||||
instance.setState({value: 1});
|
||||
expect(console.warn.calls.length).toBe(0);
|
||||
|
||||
React.unmountComponentAtNode(container);
|
||||
@@ -375,13 +375,13 @@ describe('ReactCompositeComponent', function() {
|
||||
|
||||
instance = React.render(instance, container);
|
||||
expect(function() {
|
||||
instance.setProps({ value: 1 });
|
||||
instance.setProps({value: 1});
|
||||
}).not.toThrow();
|
||||
expect(console.warn.calls.length).toBe(0);
|
||||
|
||||
React.unmountComponentAtNode(container);
|
||||
expect(function() {
|
||||
instance.setProps({ value: 2 });
|
||||
instance.setProps({value: 2});
|
||||
}).not.toThrow();
|
||||
|
||||
expect(console.warn.calls.length).toBe(1);
|
||||
@@ -757,7 +757,7 @@ describe('ReactCompositeComponent', function() {
|
||||
},
|
||||
|
||||
getChildContext: function() {
|
||||
return { foo: this.props.foo };
|
||||
return {foo: this.props.foo};
|
||||
},
|
||||
|
||||
render: function() { return <Parent><Component /></Parent>; }
|
||||
@@ -878,11 +878,11 @@ describe('ReactCompositeComponent', function() {
|
||||
var renders = 0;
|
||||
var Component = React.createClass({
|
||||
getInitialState: function() {
|
||||
return { updated: false };
|
||||
return {updated: false};
|
||||
},
|
||||
componentWillReceiveProps: function(props) {
|
||||
expect(props.update).toBe(1);
|
||||
this.setState({ updated: true });
|
||||
this.setState({updated: true});
|
||||
},
|
||||
render: function() {
|
||||
renders++;
|
||||
|
||||
@@ -26,12 +26,12 @@ describe('ReactCompositeComponentNestedState-state', function() {
|
||||
it('should provide up to date values for props', function() {
|
||||
var ParentComponent = React.createClass({
|
||||
getInitialState: function() {
|
||||
return { color: 'blue' };
|
||||
return {color: 'blue'};
|
||||
},
|
||||
|
||||
handleColor: function(color) {
|
||||
this.props.logger('parent-handleColor', this.state.color);
|
||||
this.setState({ color: color }, function() {
|
||||
this.setState({color: color}, function() {
|
||||
this.props.logger('parent-after-setState', this.state.color);
|
||||
});
|
||||
},
|
||||
@@ -49,7 +49,7 @@ describe('ReactCompositeComponentNestedState-state', function() {
|
||||
var ChildComponent = React.createClass({
|
||||
getInitialState: function() {
|
||||
this.props.logger('getInitialState', this.props.color);
|
||||
return { hue: 'dark ' + this.props.color };
|
||||
return {hue: 'dark ' + this.props.color};
|
||||
},
|
||||
|
||||
handleHue: function(shade, color) {
|
||||
@@ -58,7 +58,7 @@ describe('ReactCompositeComponentNestedState-state', function() {
|
||||
this.setState(function(state, props) {
|
||||
this.props.logger('setState-this', this.state.hue, this.props.color);
|
||||
this.props.logger('setState-args', state.hue, props.color);
|
||||
return { hue: shade + ' ' + props.color }
|
||||
return {hue: shade + ' ' + props.color}
|
||||
}, function() {
|
||||
this.props.logger('after-setState', this.state.hue, this.props.color);
|
||||
});
|
||||
|
||||
@@ -94,7 +94,7 @@ describe('ReactCompositeComponent-state', function() {
|
||||
this.peekAtState('before-setState-receiveProps', state);
|
||||
return {color: newProps.nextColor};
|
||||
});
|
||||
this.replaceState({ color: undefined });
|
||||
this.replaceState({color: undefined});
|
||||
this.setState(
|
||||
function(state) {
|
||||
this.peekAtState('before-setState-again-receiveProps', state);
|
||||
|
||||
@@ -267,11 +267,11 @@ describe('ReactIdentity', function() {
|
||||
var TestContainer = React.createClass({
|
||||
|
||||
getInitialState: function() {
|
||||
return { swapped: false };
|
||||
return {swapped: false};
|
||||
},
|
||||
|
||||
swap: function() {
|
||||
this.setState({ swapped: true });
|
||||
this.setState({swapped: true});
|
||||
},
|
||||
|
||||
render: function() {
|
||||
|
||||
@@ -353,27 +353,27 @@ describe('ReactInstanceHandles', function() {
|
||||
var parent = renderParentIntoDocument();
|
||||
var ancestors = [
|
||||
// Common ancestor from window to deep element is ''.
|
||||
{ one: null,
|
||||
{one: null,
|
||||
two: parent.refs.P_P1_C1.refs.DIV_1,
|
||||
com: null
|
||||
},
|
||||
// Same as previous - reversed direction.
|
||||
{ one: parent.refs.P_P1_C1.refs.DIV_1,
|
||||
{one: parent.refs.P_P1_C1.refs.DIV_1,
|
||||
two: null,
|
||||
com: null
|
||||
},
|
||||
// Common ancestor from window to shallow id is ''.
|
||||
{ one: parent.refs.P,
|
||||
{one: parent.refs.P,
|
||||
two: null,
|
||||
com: null
|
||||
},
|
||||
// Common ancestor with self is self.
|
||||
{ one: parent.refs.P_P1_C1.refs.DIV_1,
|
||||
{one: parent.refs.P_P1_C1.refs.DIV_1,
|
||||
two: parent.refs.P_P1_C1.refs.DIV_1,
|
||||
com: parent.refs.P_P1_C1.refs.DIV_1
|
||||
},
|
||||
// Common ancestor with self is self - even if topmost DOM.
|
||||
{ one: parent.refs.P, two: parent.refs.P, com: parent.refs.P },
|
||||
{one: parent.refs.P, two: parent.refs.P, com: parent.refs.P},
|
||||
// Siblings
|
||||
{
|
||||
one: parent.refs.P_P1_C1.refs.DIV_1,
|
||||
|
||||
@@ -30,11 +30,11 @@ describe('ReactMockedComponent', function() {
|
||||
|
||||
OriginalComponent = React.createClass({
|
||||
getDefaultProps: function() {
|
||||
return { bar: 'baz' };
|
||||
return {bar: 'baz'};
|
||||
},
|
||||
|
||||
getInitialState: function() {
|
||||
return { foo: 'bar' };
|
||||
return {foo: 'bar'};
|
||||
},
|
||||
|
||||
hasCustomMethod: function() {
|
||||
@@ -65,11 +65,11 @@ describe('ReactMockedComponent', function() {
|
||||
var Wrapper = React.createClass({
|
||||
|
||||
getInitialState: function() {
|
||||
return { foo: 1 };
|
||||
return {foo: 1};
|
||||
},
|
||||
|
||||
update: function() {
|
||||
this.setState({ foo: 2 });
|
||||
this.setState({foo: 2});
|
||||
},
|
||||
|
||||
render: function() {
|
||||
@@ -105,11 +105,11 @@ describe('ReactMockedComponent', function() {
|
||||
var Wrapper = React.createClass({
|
||||
|
||||
getInitialState: function() {
|
||||
return { foo: 1 };
|
||||
return {foo: 1};
|
||||
},
|
||||
|
||||
update: function() {
|
||||
this.setState({ foo: 2 });
|
||||
this.setState({foo: 2});
|
||||
},
|
||||
|
||||
render: function() {
|
||||
|
||||
@@ -51,7 +51,7 @@ var getOriginalKey = function(childName) {
|
||||
*/
|
||||
var StatusDisplay = React.createClass({
|
||||
getInitialState: function() {
|
||||
return { internalState: Math.random() };
|
||||
return {internalState: Math.random()};
|
||||
},
|
||||
|
||||
getStatus: function() {
|
||||
@@ -251,7 +251,7 @@ describe('ReactMultiChildReconcile', function() {
|
||||
var startingInternalState = statusDisplays.jcw.getInternalState();
|
||||
|
||||
// Now remove the child.
|
||||
parentInstance.replaceProps({ usernameToStatus: {} });
|
||||
parentInstance.replaceProps({usernameToStatus: {} });
|
||||
statusDisplays = parentInstance.getStatusDisplays();
|
||||
expect(statusDisplays.jcw).toBeFalsy();
|
||||
|
||||
@@ -271,7 +271,7 @@ describe('ReactMultiChildReconcile', function() {
|
||||
bob: 'bobStatus'
|
||||
};
|
||||
|
||||
testPropsSequence([ { usernameToStatus: usernameToStatus } ]);
|
||||
testPropsSequence([ {usernameToStatus: usernameToStatus} ]);
|
||||
});
|
||||
|
||||
it('should preserve order if children order has not changed', function() {
|
||||
@@ -294,7 +294,7 @@ describe('ReactMultiChildReconcile', function() {
|
||||
|
||||
it('should transition from zero to one children correctly', function() {
|
||||
var PROPS_SEQUENCE = [
|
||||
{ usernameToStatus: {} },
|
||||
{usernameToStatus: {} },
|
||||
{
|
||||
usernameToStatus: {
|
||||
first: 'firstStatus'
|
||||
@@ -311,7 +311,7 @@ describe('ReactMultiChildReconcile', function() {
|
||||
first: 'firstStatus'
|
||||
}
|
||||
},
|
||||
{ usernameToStatus: {} }
|
||||
{usernameToStatus: {} }
|
||||
];
|
||||
testPropsSequence(PROPS_SEQUENCE);
|
||||
});
|
||||
@@ -323,13 +323,13 @@ describe('ReactMultiChildReconcile', function() {
|
||||
first: 'firstStatus'
|
||||
}
|
||||
},
|
||||
{ }
|
||||
{}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should transition from null children to one child', function() {
|
||||
testPropsSequence([
|
||||
{ },
|
||||
{},
|
||||
{
|
||||
usernameToStatus: {
|
||||
first: 'firstStatus'
|
||||
@@ -341,17 +341,17 @@ describe('ReactMultiChildReconcile', function() {
|
||||
it('should transition from zero children to null children', function() {
|
||||
testPropsSequence([
|
||||
{
|
||||
usernameToStatus: { }
|
||||
usernameToStatus: {}
|
||||
},
|
||||
{ }
|
||||
{}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should transition from null children to zero children', function() {
|
||||
testPropsSequence([
|
||||
{ },
|
||||
{},
|
||||
{
|
||||
usernameToStatus: { }
|
||||
usernameToStatus: {}
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -858,7 +858,7 @@ describe('ReactUpdates', function() {
|
||||
|
||||
var B = React.createClass({
|
||||
getInitialState: function() {
|
||||
return { updates: 0 };
|
||||
return {updates: 0};
|
||||
},
|
||||
componentDidMount: function() {
|
||||
componentB = this;
|
||||
@@ -871,7 +871,7 @@ describe('ReactUpdates', function() {
|
||||
|
||||
var A = React.createClass({
|
||||
getInitialState: function() {
|
||||
return { showB: true };
|
||||
return {showB: true};
|
||||
},
|
||||
render: function() {
|
||||
return this.state.showB ? <B /> : <div />;
|
||||
@@ -883,8 +883,8 @@ describe('ReactUpdates', function() {
|
||||
ReactUpdates.batchedUpdates(function() {
|
||||
// B will have scheduled an update but the batching should ensure that its
|
||||
// update never fires.
|
||||
componentB.setState({ updates: 1 });
|
||||
component.setState({ showB: false });
|
||||
componentB.setState({updates: 1});
|
||||
component.setState({showB: false});
|
||||
});
|
||||
|
||||
expect(renderCount).toBe(1);
|
||||
|
||||
@@ -166,7 +166,7 @@ describe('ref swapping', function() {
|
||||
return {count: 0};
|
||||
},
|
||||
moveRef: function() {
|
||||
this.setState({ count: this.state.count + 1 });
|
||||
this.setState({count: this.state.count + 1});
|
||||
},
|
||||
render: function() {
|
||||
var count = this.state.count;
|
||||
|
||||
@@ -69,7 +69,7 @@ describe('ReactES6Class', function() {
|
||||
class Foo extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = { bar: this.props.initialValue };
|
||||
this.state = {bar: this.props.initialValue};
|
||||
}
|
||||
render() {
|
||||
return <span className={this.state.bar} />;
|
||||
@@ -81,10 +81,10 @@ describe('ReactES6Class', function() {
|
||||
it('renders based on state using props in the constructor', function() {
|
||||
class Foo extends React.Component {
|
||||
constructor(props) {
|
||||
this.state = { bar: props.initialValue };
|
||||
this.state = {bar: props.initialValue};
|
||||
}
|
||||
changeState() {
|
||||
this.setState({ bar: 'bar' });
|
||||
this.setState({bar: 'bar'});
|
||||
}
|
||||
render() {
|
||||
if (this.state.bar === 'foo') {
|
||||
@@ -102,7 +102,7 @@ describe('ReactES6Class', function() {
|
||||
class Foo extends React.Component {
|
||||
constructor(props, context) {
|
||||
super(props, context);
|
||||
this.state = { tag: context.tag, className: this.context.className };
|
||||
this.state = {tag: context.tag, className: this.context.className};
|
||||
}
|
||||
render() {
|
||||
var Tag = this.state.tag;
|
||||
@@ -116,7 +116,7 @@ describe('ReactES6Class', function() {
|
||||
|
||||
class Outer extends React.Component {
|
||||
getChildContext() {
|
||||
return { tag: 'span', className: 'foo' };
|
||||
return {tag: 'span', className: 'foo'};
|
||||
}
|
||||
render() {
|
||||
return <Foo />;
|
||||
@@ -133,10 +133,10 @@ describe('ReactES6Class', function() {
|
||||
var renderCount = 0;
|
||||
class Foo extends React.Component {
|
||||
constructor(props) {
|
||||
this.state = { bar: props.initialValue };
|
||||
this.state = {bar: props.initialValue};
|
||||
}
|
||||
componentWillMount() {
|
||||
this.setState({ bar: 'bar' });
|
||||
this.setState({bar: 'bar'});
|
||||
}
|
||||
render() {
|
||||
renderCount++;
|
||||
@@ -179,10 +179,10 @@ describe('ReactES6Class', function() {
|
||||
it('setState through an event handler', function() {
|
||||
class Foo extends React.Component {
|
||||
constructor(props) {
|
||||
this.state = { bar: props.initialValue };
|
||||
this.state = {bar: props.initialValue};
|
||||
}
|
||||
handleClick() {
|
||||
this.setState({ bar: 'bar' });
|
||||
this.setState({bar: 'bar'});
|
||||
}
|
||||
render() {
|
||||
return (
|
||||
@@ -201,10 +201,10 @@ describe('ReactES6Class', function() {
|
||||
it('should not implicitly bind event handlers', function() {
|
||||
class Foo extends React.Component {
|
||||
constructor(props) {
|
||||
this.state = { bar: props.initialValue };
|
||||
this.state = {bar: props.initialValue};
|
||||
}
|
||||
handleClick() {
|
||||
this.setState({ bar: 'bar' });
|
||||
this.setState({bar: 'bar'});
|
||||
}
|
||||
render() {
|
||||
return (
|
||||
@@ -282,10 +282,10 @@ describe('ReactES6Class', function() {
|
||||
lifeCycles = []; // reset
|
||||
test(<Foo value="bar" />, 'SPAN', 'bar');
|
||||
expect(lifeCycles).toEqual([
|
||||
'receive-props', { value: 'bar' },
|
||||
'should-update', { value: 'bar' }, {},
|
||||
'will-update', { value: 'bar' }, {},
|
||||
'did-update', { value: 'foo' }, {}
|
||||
'receive-props', {value: 'bar'},
|
||||
'should-update', {value: 'bar'}, {},
|
||||
'will-update', {value: 'bar'}, {},
|
||||
'did-update', {value: 'foo'}, {}
|
||||
]);
|
||||
lifeCycles = []; // reset
|
||||
React.unmountComponentAtNode(container);
|
||||
@@ -353,7 +353,7 @@ describe('ReactES6Class', function() {
|
||||
expect(() => instance.getDOMNode()).toThrow();
|
||||
expect(() => instance.replaceState({})).toThrow();
|
||||
expect(() => instance.isMounted()).toThrow();
|
||||
expect(() => instance.setProps({ name: 'bar' })).toThrow();
|
||||
expect(() => instance.setProps({name: 'bar'})).toThrow();
|
||||
expect(console.warn.calls.length).toBe(4);
|
||||
expect(console.warn.calls[0].args[0]).toContain(
|
||||
'getDOMNode(...) is deprecated in plain JavaScript React classes'
|
||||
@@ -375,16 +375,16 @@ describe('ReactES6Class', function() {
|
||||
return <div className={this.context.bar} />;
|
||||
}
|
||||
}
|
||||
Bar.contextTypes = { bar: React.PropTypes.string };
|
||||
Bar.contextTypes = {bar: React.PropTypes.string};
|
||||
class Foo {
|
||||
getChildContext() {
|
||||
return { bar: 'bar-through-context' };
|
||||
return {bar: 'bar-through-context'};
|
||||
}
|
||||
render() {
|
||||
return <Bar />;
|
||||
}
|
||||
}
|
||||
Foo.childContextTypes = { bar: React.PropTypes.string };
|
||||
Foo.childContextTypes = {bar: React.PropTypes.string};
|
||||
test(<Foo />, 'DIV', 'bar-through-context');
|
||||
});
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ describe('ReactJSXElement', function() {
|
||||
});
|
||||
|
||||
it('does not reuse the object that is spread into props', function() {
|
||||
var config = { foo: 1 };
|
||||
var config = {foo: 1};
|
||||
var element = <Component {...config} />;
|
||||
expect(element.props.foo).toBe(1);
|
||||
config.foo = 2;
|
||||
@@ -161,7 +161,7 @@ describe('ReactJSXElement', function() {
|
||||
return <span />;
|
||||
}
|
||||
}
|
||||
Component.defaultProps = { fruit: 'persimmon' };
|
||||
Component.defaultProps = {fruit: 'persimmon'};
|
||||
|
||||
var container = document.createElement('div');
|
||||
var instance = React.render(
|
||||
@@ -180,7 +180,7 @@ describe('ReactJSXElement', function() {
|
||||
return <span>{this.props.prop}</span>;
|
||||
}
|
||||
}
|
||||
Component.defaultProps = { prop: 'testKey' };
|
||||
Component.defaultProps = {prop: 'testKey'};
|
||||
|
||||
var instance = ReactTestUtils.renderIntoDocument(<Component />);
|
||||
expect(instance.props.prop).toBe('testKey');
|
||||
|
||||
@@ -86,7 +86,7 @@ describe('ReactJSXElementValidator', function() {
|
||||
return {
|
||||
next: function() {
|
||||
var done = ++i > 2;
|
||||
return { value: done ? undefined : <Component />, done: done };
|
||||
return {value: done ? undefined : <Component />, done: done};
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -134,7 +134,7 @@ describe('ReactJSXElementValidator', function() {
|
||||
it('warns for numeric keys on objects as children', function() {
|
||||
spyOn(console, 'warn');
|
||||
|
||||
<Component>{frag({ 1: <Component />, 2: <Component /> })}</Component>;
|
||||
<Component>{frag({1: <Component />, 2: <Component />})}</Component>;
|
||||
|
||||
expect(console.warn.argsForCall.length).toBe(1);
|
||||
expect(console.warn.argsForCall[0][0]).toContain(
|
||||
@@ -151,7 +151,7 @@ describe('ReactJSXElementValidator', function() {
|
||||
return {
|
||||
next: function() {
|
||||
var done = ++i > 2;
|
||||
return { value: done ? undefined : [i, <Component />], done: done };
|
||||
return {value: done ? undefined : [i, <Component />], done: done};
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -236,8 +236,8 @@ describe('ReactJSXElementValidator', function() {
|
||||
return <span>{this.props.prop}</span>;
|
||||
}
|
||||
}
|
||||
Component.defaultProps = { prop: null };
|
||||
Component.propTypes = { prop: React.PropTypes.string.isRequired };
|
||||
Component.defaultProps = {prop: null};
|
||||
Component.propTypes = {prop: React.PropTypes.string.isRequired};
|
||||
|
||||
ReactTestUtils.renderIntoDocument(<Component />);
|
||||
|
||||
@@ -256,8 +256,8 @@ describe('ReactJSXElementValidator', function() {
|
||||
return <span>{this.props.prop}</span>;
|
||||
}
|
||||
}
|
||||
Component.defaultProps = { prop: 'text' };
|
||||
Component.propTypes = { prop: React.PropTypes.string.isRequired };
|
||||
Component.defaultProps = {prop: 'text'};
|
||||
Component.propTypes = {prop: React.PropTypes.string.isRequired};
|
||||
|
||||
ReactTestUtils.renderIntoDocument(<Component prop={null} />);
|
||||
|
||||
|
||||
@@ -424,7 +424,7 @@ describe('ReactChildren', function() {
|
||||
it('should warn if a fragment is used without the wrapper', function() {
|
||||
spyOn(console, 'warn');
|
||||
var child = React.createElement('span');
|
||||
ReactChildren.forEach({ a: child, b: child}, function(c) {
|
||||
ReactChildren.forEach({a: child, b: child}, function(c) {
|
||||
expect(c).toBe(child);
|
||||
});
|
||||
expect(console.warn.calls.length).toBe(1);
|
||||
|
||||
@@ -300,9 +300,9 @@ describe('traverseAllChildren', function() {
|
||||
return {
|
||||
next: function() {
|
||||
if (i++ < 3) {
|
||||
return { value: <div />, done: false };
|
||||
return {value: <div />, done: false};
|
||||
} else {
|
||||
return { value: undefined, done: true };
|
||||
return {value: undefined, done: true};
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -351,9 +351,9 @@ describe('traverseAllChildren', function() {
|
||||
return {
|
||||
next: function() {
|
||||
if (i++ < 3) {
|
||||
return { value: <div key={'#' + i} />, done: false };
|
||||
return {value: <div key={'#' + i} />, done: false};
|
||||
} else {
|
||||
return { value: undefined, done: true };
|
||||
return {value: undefined, done: true};
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -404,9 +404,9 @@ describe('traverseAllChildren', function() {
|
||||
return {
|
||||
next: function() {
|
||||
if (i++ < 3) {
|
||||
return { value: ['#' + i, <div />], done: false };
|
||||
return {value: ['#' + i, <div />], done: false};
|
||||
} else {
|
||||
return { value: undefined, done: true };
|
||||
return {value: undefined, done: true};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ describe('keyMirror', function() {
|
||||
var mirror = keyMirror({
|
||||
foo: null,
|
||||
bar: true,
|
||||
"baz": { some: "object" },
|
||||
"baz": {some: "object"},
|
||||
qux: undefined
|
||||
});
|
||||
expect('foo' in mirror).toBe(true);
|
||||
@@ -55,7 +55,7 @@ describe('keyMirror', function() {
|
||||
});
|
||||
|
||||
it('should work when "constructor" is a key', function() {
|
||||
var obj = { constructor: true };
|
||||
var obj = {constructor: true};
|
||||
expect(keyMirror.bind(null, obj)).not.toThrow();
|
||||
var mirror = keyMirror(obj);
|
||||
expect('constructor' in mirror).toBe(true);
|
||||
|
||||
+3
-3
@@ -350,13 +350,13 @@ describe('react jsx', function() {
|
||||
it('calls assign with an empty object when the spread is first', function() {
|
||||
expectObjectAssign(
|
||||
'<Component { ...x } y={2} />'
|
||||
).toBeCalledWith({}, x, { y: 2 });
|
||||
).toBeCalledWith({}, x, {y: 2});
|
||||
});
|
||||
|
||||
it('coalesces consecutive properties into a single object', function() {
|
||||
expectObjectAssign(
|
||||
'<Component { ... x } y={2} z />'
|
||||
).toBeCalledWith({}, x, { y: 2, z: true });
|
||||
).toBeCalledWith({}, x, {y: 2, z: true});
|
||||
});
|
||||
|
||||
it('avoids an unnecessary empty object when spread is not first', function() {
|
||||
@@ -374,7 +374,7 @@ describe('react jsx', function() {
|
||||
it('evaluates sequences before passing them to React.__spread', function() {
|
||||
expectObjectAssign(
|
||||
'<Component x="1" {...(z = { y: 2 }, z)} z={3}>Text</Component>'
|
||||
).toBeCalledWith({x: "1"}, { y: 2 }, {z: 3});
|
||||
).toBeCalledWith({x: "1"}, {y: 2}, {z: 3});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user