mirror of
https://github.com/facebook/react.git
synced 2026-11-18 20:15:56 +00:00
Add build process for createReactClass (#9943)
* Switch trailing comma to ES5 mode in addons * Add build process for createReactClass * Test UMD bundles on CI * Fix lint
This commit is contained in:
1 parent
dea8f6a653
commit
f127ba6b21
30 files changed
+1102
-208
No files matched your search
+1
-1
@@ -21,7 +21,7 @@ module.exports = {
|
||||
'dot-notation': ERROR,
|
||||
'eol-last': ERROR,
|
||||
'eqeqeq': [ERROR, 'allow-null'],
|
||||
'indent': [ERROR, 2, {SwitchCase: 1}],
|
||||
'indent': OFF, // We use Prettier now
|
||||
'jsx-quotes': [ERROR, 'prefer-double'],
|
||||
'keyword-spacing': [ERROR, {after: true, before: true}],
|
||||
'no-bitwise': OFF,
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
create-react-class.js
|
||||
create-react-class.min.js
|
||||
@@ -314,7 +314,7 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) {
|
||||
Constructor.childContextTypes = _assign(
|
||||
{},
|
||||
Constructor.childContextTypes,
|
||||
childContextTypes,
|
||||
childContextTypes
|
||||
);
|
||||
},
|
||||
contextTypes: function(Constructor, contextTypes) {
|
||||
@@ -324,7 +324,7 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) {
|
||||
Constructor.contextTypes = _assign(
|
||||
{},
|
||||
Constructor.contextTypes,
|
||||
contextTypes,
|
||||
contextTypes
|
||||
);
|
||||
},
|
||||
/**
|
||||
@@ -335,7 +335,7 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) {
|
||||
if (Constructor.getDefaultProps) {
|
||||
Constructor.getDefaultProps = createMergedResultFunction(
|
||||
Constructor.getDefaultProps,
|
||||
getDefaultProps,
|
||||
getDefaultProps
|
||||
);
|
||||
} else {
|
||||
Constructor.getDefaultProps = getDefaultProps;
|
||||
@@ -365,7 +365,7 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) {
|
||||
'React.PropTypes.',
|
||||
Constructor.displayName || 'ReactClass',
|
||||
ReactPropTypeLocationNames[location],
|
||||
propName,
|
||||
propName
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -384,7 +384,7 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) {
|
||||
'ReactClassInterface: You are attempting to override ' +
|
||||
'`%s` from your class specification. Ensure that your method names ' +
|
||||
'do not overlap with React methods.',
|
||||
name,
|
||||
name
|
||||
);
|
||||
}
|
||||
|
||||
@@ -395,7 +395,7 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) {
|
||||
'ReactClassInterface: You are attempting to define ' +
|
||||
'`%s` on your component more than once. This conflict may be due ' +
|
||||
'to a mixin.',
|
||||
name,
|
||||
name
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -418,7 +418,7 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) {
|
||||
'as well as any mixins they include themselves. ' +
|
||||
'Expected object but got %s.',
|
||||
Constructor.displayName || 'ReactClass',
|
||||
spec === null ? null : typeofSpec,
|
||||
spec === null ? null : typeofSpec
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -430,12 +430,12 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) {
|
||||
typeof spec !== 'function',
|
||||
"ReactClass: You're attempting to " +
|
||||
'use a component class or function as a mixin. Instead, just use a ' +
|
||||
'regular object.',
|
||||
'regular object.'
|
||||
);
|
||||
_invariant(
|
||||
!isValidElement(spec),
|
||||
"ReactClass: You're attempting to " +
|
||||
'use a component as a mixin. Instead, just use a regular object.',
|
||||
'use a component as a mixin. Instead, just use a regular object.'
|
||||
);
|
||||
|
||||
var proto = Constructor.prototype;
|
||||
@@ -492,7 +492,7 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) {
|
||||
'ReactClass: Unexpected spec policy %s for key %s ' +
|
||||
'when mixing in component specs.',
|
||||
specPolicy,
|
||||
name,
|
||||
name
|
||||
);
|
||||
|
||||
// For methods which are defined more than once, call the existing
|
||||
@@ -534,7 +534,7 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) {
|
||||
'property, `%s`, that shouldn\'t be on the "statics" key. Define it ' +
|
||||
'as an instance property instead; it will still be accessible on the ' +
|
||||
'constructor.',
|
||||
name,
|
||||
name
|
||||
);
|
||||
|
||||
var isInherited = name in Constructor;
|
||||
@@ -543,7 +543,7 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) {
|
||||
'ReactClass: You are attempting to define ' +
|
||||
'`%s` on your component more than once. This conflict may be ' +
|
||||
'due to a mixin.',
|
||||
name,
|
||||
name
|
||||
);
|
||||
Constructor[name] = property;
|
||||
}
|
||||
@@ -559,7 +559,7 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) {
|
||||
function mergeIntoWithNoDuplicateKeys(one, two) {
|
||||
_invariant(
|
||||
one && two && typeof one === 'object' && typeof two === 'object',
|
||||
'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.',
|
||||
'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.'
|
||||
);
|
||||
|
||||
for (var key in two) {
|
||||
@@ -571,7 +571,7 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) {
|
||||
'may be due to a mixin; in particular, this may be caused by two ' +
|
||||
'getInitialState() or getDefaultProps() methods returning objects ' +
|
||||
'with clashing keys.',
|
||||
key,
|
||||
key
|
||||
);
|
||||
one[key] = two[key];
|
||||
}
|
||||
@@ -653,7 +653,7 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) {
|
||||
false,
|
||||
'bind(): React component methods may only be bound to the ' +
|
||||
'component instance. See %s',
|
||||
componentName,
|
||||
componentName
|
||||
);
|
||||
}
|
||||
} else if (!args.length) {
|
||||
@@ -663,7 +663,7 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) {
|
||||
'bind(): You are binding a component method to the component. ' +
|
||||
'React does this for you automatically in a high-performance ' +
|
||||
'way, so you can safely remove this call. See %s',
|
||||
componentName,
|
||||
componentName
|
||||
);
|
||||
}
|
||||
return boundMethod;
|
||||
@@ -732,7 +732,7 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) {
|
||||
'prevent memory leaks.',
|
||||
(this.constructor && this.constructor.displayName) ||
|
||||
this.name ||
|
||||
'Component',
|
||||
'Component'
|
||||
);
|
||||
this.__didWarnIsMounted = true;
|
||||
}
|
||||
@@ -744,7 +744,7 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) {
|
||||
_assign(
|
||||
ReactClassComponent.prototype,
|
||||
ReactComponent.prototype,
|
||||
ReactClassMixin,
|
||||
ReactClassMixin
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -767,7 +767,7 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) {
|
||||
warning(
|
||||
this instanceof Constructor,
|
||||
'Something is calling a React component directly. Use a factory or ' +
|
||||
'JSX instead. See: https://fb.me/react-legacyfactory',
|
||||
'JSX instead. See: https://fb.me/react-legacyfactory'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -801,7 +801,7 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) {
|
||||
_invariant(
|
||||
typeof initialState === 'object' && !Array.isArray(initialState),
|
||||
'%s.getInitialState(): must return an object or null',
|
||||
Constructor.displayName || 'ReactCompositeComponent',
|
||||
Constructor.displayName || 'ReactCompositeComponent'
|
||||
);
|
||||
|
||||
this.state = initialState;
|
||||
@@ -836,7 +836,7 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) {
|
||||
|
||||
_invariant(
|
||||
Constructor.prototype.render,
|
||||
'createClass(...): Class specification must implement a `render` method.',
|
||||
'createClass(...): Class specification must implement a `render` method.'
|
||||
);
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
@@ -846,13 +846,13 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) {
|
||||
'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' +
|
||||
'The name is phrased as a question because the function is ' +
|
||||
'expected to return a value.',
|
||||
spec.displayName || 'A component',
|
||||
spec.displayName || 'A component'
|
||||
);
|
||||
warning(
|
||||
!Constructor.prototype.componentWillRecieveProps,
|
||||
'%s has a method called ' +
|
||||
'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?',
|
||||
spec.displayName || 'A component',
|
||||
spec.displayName || 'A component'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,11 +13,18 @@
|
||||
var React = require('react');
|
||||
var factory = require('./factory');
|
||||
|
||||
if (typeof React === 'undefined') {
|
||||
throw Error(
|
||||
'createReactClass could not find the React object. If you are using script tags, ' +
|
||||
'make sure that React is being loaded before createReactClass.'
|
||||
);
|
||||
}
|
||||
|
||||
// Hack to grab NoopUpdateQueue from isomorphic React
|
||||
var ReactNoopUpdateQueue = new React.Component().updater;
|
||||
|
||||
module.exports = factory(
|
||||
React.Component,
|
||||
React.isValidElement,
|
||||
ReactNoopUpdateQueue,
|
||||
ReactNoopUpdateQueue
|
||||
);
|
||||
@@ -26,13 +26,18 @@
|
||||
"object-assign": "^4.1.1"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "jest"
|
||||
"test": "TEST_ENTRY=./index.js jest",
|
||||
"build:dev": "NODE_ENV=development webpack && TEST_ENTRY=./create-react-class.js jest",
|
||||
"build:prod": "NODE_ENV=production webpack && NODE_ENV=production TEST_ENTRY=./create-react-class.min.js jest",
|
||||
"build": "npm run build:dev && npm run build:prod",
|
||||
"prepublish": "npm test && npm run build"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jest": "^19.0.2",
|
||||
"react": "^15.5.0",
|
||||
"react-addons-test-utils": "^15.5.0",
|
||||
"react-dom": "^15.5.0"
|
||||
"prop-types": "^15.5.10",
|
||||
"react": "^15.5.4",
|
||||
"react-dom": "^15.5.4",
|
||||
"webpack": "^2.6.1"
|
||||
},
|
||||
"browserify": {
|
||||
"transform": [
|
||||
|
||||
@@ -11,39 +11,95 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var PropTypes;
|
||||
var React;
|
||||
var ReactDOM;
|
||||
var ReactTestUtils;
|
||||
var createReactClass;
|
||||
|
||||
// For testing DOM Fiber.
|
||||
global.requestAnimationFrame = function(callback) {
|
||||
setTimeout(callback);
|
||||
// Catch stray warnings
|
||||
var env = jasmine.getEnv();
|
||||
var callCount = 0;
|
||||
var oldError = console.error;
|
||||
var newError = function() {
|
||||
callCount++;
|
||||
oldError.apply(this, arguments);
|
||||
};
|
||||
|
||||
global.requestIdleCallback = function(callback) {
|
||||
setTimeout(() => {
|
||||
callback({
|
||||
timeRemaining() {
|
||||
return Infinity;
|
||||
},
|
||||
});
|
||||
console.error = newError;
|
||||
env.beforeEach(() => {
|
||||
callCount = 0;
|
||||
jasmine.addMatchers({
|
||||
toBeReset() {
|
||||
return {
|
||||
compare(actual) {
|
||||
if (actual !== newError && !jasmine.isSpy(actual)) {
|
||||
return {
|
||||
pass: false,
|
||||
message: 'Test did not tear down console.error mock properly.',
|
||||
};
|
||||
}
|
||||
return {pass: true};
|
||||
},
|
||||
};
|
||||
},
|
||||
toNotHaveBeenCalled() {
|
||||
return {
|
||||
compare(actual) {
|
||||
return {
|
||||
pass: callCount === 0,
|
||||
message: 'Expected test not to warn. If the warning is expected, mock ' +
|
||||
"it out using spyOn(console, 'error'); and test that the " +
|
||||
'warning occurs.',
|
||||
};
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
};
|
||||
});
|
||||
env.afterEach(() => {
|
||||
expect(console.error).toBeReset();
|
||||
expect(console.error).toNotHaveBeenCalled();
|
||||
});
|
||||
|
||||
// Suppress warning expectations for prod builds
|
||||
function suppressDevMatcher(obj, name) {
|
||||
const original = obj[name];
|
||||
obj[name] = function devMatcher() {
|
||||
try {
|
||||
original.apply(this, arguments);
|
||||
} catch (e) {
|
||||
// skip
|
||||
}
|
||||
};
|
||||
}
|
||||
function expectDev(actual) {
|
||||
const expectation = expect(actual);
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
Object.keys(expectation).forEach(name => {
|
||||
suppressDevMatcher(expectation, name);
|
||||
suppressDevMatcher(expectation.not, name);
|
||||
});
|
||||
}
|
||||
return expectation;
|
||||
}
|
||||
|
||||
function renderIntoDocument(element) {
|
||||
var node = document.createElement('div');
|
||||
return ReactDOM.render(element, node);
|
||||
}
|
||||
|
||||
describe('ReactClass-spec', () => {
|
||||
beforeEach(() => {
|
||||
PropTypes = require('prop-types');
|
||||
React = require('react');
|
||||
ReactDOM = require('react-dom');
|
||||
ReactTestUtils = require('react-addons-test-utils');
|
||||
createReactClass = require('./index');
|
||||
createReactClass = require(process.env.TEST_ENTRY);
|
||||
});
|
||||
|
||||
it('should throw when `render` is not specified', () => {
|
||||
expect(function() {
|
||||
createReactClass({});
|
||||
}).toThrowError(
|
||||
'createClass(...): Class specification must implement a `render` method.',
|
||||
'createClass(...): Class specification must implement a `render` method.'
|
||||
);
|
||||
});
|
||||
|
||||
@@ -84,10 +140,10 @@ describe('ReactClass-spec', () => {
|
||||
return <span>{this.props.prop}</span>;
|
||||
},
|
||||
});
|
||||
expect(console.error.calls.count()).toBe(1);
|
||||
expect(console.error.calls.argsFor(0)[0]).toBe(
|
||||
expectDev(console.error.calls.count()).toBe(1);
|
||||
expectDev(console.error.calls.argsFor(0)[0]).toBe(
|
||||
'Warning: Component: prop type `prop` is invalid; ' +
|
||||
'it must be a function, usually from React.PropTypes.',
|
||||
'it must be a function, usually from React.PropTypes.'
|
||||
);
|
||||
});
|
||||
|
||||
@@ -102,10 +158,10 @@ describe('ReactClass-spec', () => {
|
||||
return <span>{this.props.prop}</span>;
|
||||
},
|
||||
});
|
||||
expect(console.error.calls.count()).toBe(1);
|
||||
expect(console.error.calls.argsFor(0)[0]).toBe(
|
||||
expectDev(console.error.calls.count()).toBe(1);
|
||||
expectDev(console.error.calls.argsFor(0)[0]).toBe(
|
||||
'Warning: Component: context type `prop` is invalid; ' +
|
||||
'it must be a function, usually from React.PropTypes.',
|
||||
'it must be a function, usually from React.PropTypes.'
|
||||
);
|
||||
});
|
||||
|
||||
@@ -120,10 +176,10 @@ describe('ReactClass-spec', () => {
|
||||
return <span>{this.props.prop}</span>;
|
||||
},
|
||||
});
|
||||
expect(console.error.calls.count()).toBe(1);
|
||||
expect(console.error.calls.argsFor(0)[0]).toBe(
|
||||
expectDev(console.error.calls.count()).toBe(1);
|
||||
expectDev(console.error.calls.argsFor(0)[0]).toBe(
|
||||
'Warning: Component: child context type `prop` is invalid; ' +
|
||||
'it must be a function, usually from React.PropTypes.',
|
||||
'it must be a function, usually from React.PropTypes.'
|
||||
);
|
||||
});
|
||||
|
||||
@@ -138,11 +194,11 @@ describe('ReactClass-spec', () => {
|
||||
return <div />;
|
||||
},
|
||||
});
|
||||
expect(console.error.calls.count()).toBe(1);
|
||||
expect(console.error.calls.argsFor(0)[0]).toBe(
|
||||
expectDev(console.error.calls.count()).toBe(1);
|
||||
expectDev(console.error.calls.argsFor(0)[0]).toBe(
|
||||
'Warning: A component has a method called componentShouldUpdate(). Did you ' +
|
||||
'mean shouldComponentUpdate()? The name is phrased as a question ' +
|
||||
'because the function is expected to return a value.',
|
||||
'because the function is expected to return a value.'
|
||||
);
|
||||
|
||||
createReactClass({
|
||||
@@ -154,11 +210,11 @@ describe('ReactClass-spec', () => {
|
||||
return <div />;
|
||||
},
|
||||
});
|
||||
expect(console.error.calls.count()).toBe(2);
|
||||
expect(console.error.calls.argsFor(1)[0]).toBe(
|
||||
expectDev(console.error.calls.count()).toBe(2);
|
||||
expectDev(console.error.calls.argsFor(1)[0]).toBe(
|
||||
'Warning: NamedComponent has a method called componentShouldUpdate(). Did you ' +
|
||||
'mean shouldComponentUpdate()? The name is phrased as a question ' +
|
||||
'because the function is expected to return a value.',
|
||||
'because the function is expected to return a value.'
|
||||
);
|
||||
});
|
||||
|
||||
@@ -172,10 +228,10 @@ describe('ReactClass-spec', () => {
|
||||
return <div />;
|
||||
},
|
||||
});
|
||||
expect(console.error.calls.count()).toBe(1);
|
||||
expect(console.error.calls.argsFor(0)[0]).toBe(
|
||||
expectDev(console.error.calls.count()).toBe(1);
|
||||
expectDev(console.error.calls.argsFor(0)[0]).toBe(
|
||||
'Warning: A component has a method called componentWillRecieveProps(). Did you ' +
|
||||
'mean componentWillReceiveProps()?',
|
||||
'mean componentWillReceiveProps()?'
|
||||
);
|
||||
});
|
||||
|
||||
@@ -198,7 +254,7 @@ describe('ReactClass-spec', () => {
|
||||
'ReactClass: You are attempting to define a reserved property, ' +
|
||||
'`getDefaultProps`, that shouldn\'t be on the "statics" key. Define ' +
|
||||
'it as an instance property instead; it will still be accessible on ' +
|
||||
'the constructor.',
|
||||
'the constructor.'
|
||||
);
|
||||
});
|
||||
|
||||
@@ -208,34 +264,34 @@ describe('ReactClass-spec', () => {
|
||||
createReactClass({
|
||||
mixins: [{}],
|
||||
propTypes: {
|
||||
foo: React.PropTypes.string,
|
||||
foo: PropTypes.string,
|
||||
},
|
||||
contextTypes: {
|
||||
foo: React.PropTypes.string,
|
||||
foo: PropTypes.string,
|
||||
},
|
||||
childContextTypes: {
|
||||
foo: React.PropTypes.string,
|
||||
foo: PropTypes.string,
|
||||
},
|
||||
render: function() {
|
||||
return <div />;
|
||||
},
|
||||
});
|
||||
expect(console.error.calls.count()).toBe(4);
|
||||
expect(console.error.calls.argsFor(0)[0]).toBe(
|
||||
expectDev(console.error.calls.count()).toBe(4);
|
||||
expectDev(console.error.calls.argsFor(0)[0]).toBe(
|
||||
'createClass(...): `mixins` is now a static property and should ' +
|
||||
'be defined inside "statics".',
|
||||
'be defined inside "statics".'
|
||||
);
|
||||
expect(console.error.calls.argsFor(1)[0]).toBe(
|
||||
expectDev(console.error.calls.argsFor(1)[0]).toBe(
|
||||
'createClass(...): `propTypes` is now a static property and should ' +
|
||||
'be defined inside "statics".',
|
||||
'be defined inside "statics".'
|
||||
);
|
||||
expect(console.error.calls.argsFor(2)[0]).toBe(
|
||||
expectDev(console.error.calls.argsFor(2)[0]).toBe(
|
||||
'createClass(...): `contextTypes` is now a static property and ' +
|
||||
'should be defined inside "statics".',
|
||||
'should be defined inside "statics".'
|
||||
);
|
||||
expect(console.error.calls.argsFor(3)[0]).toBe(
|
||||
expectDev(console.error.calls.argsFor(3)[0]).toBe(
|
||||
'createClass(...): `childContextTypes` is now a static property and ' +
|
||||
'should be defined inside "statics".',
|
||||
'should be defined inside "statics".'
|
||||
);
|
||||
});
|
||||
|
||||
@@ -256,7 +312,7 @@ describe('ReactClass-spec', () => {
|
||||
},
|
||||
});
|
||||
var instance = <Component />;
|
||||
instance = ReactTestUtils.renderIntoDocument(instance);
|
||||
instance = renderIntoDocument(instance);
|
||||
expect(instance.constructor.abc).toBe('def');
|
||||
expect(Component.abc).toBe('def');
|
||||
expect(instance.constructor.def).toBe(0);
|
||||
@@ -281,14 +337,14 @@ describe('ReactClass-spec', () => {
|
||||
},
|
||||
});
|
||||
var instance = <Component />;
|
||||
instance = ReactTestUtils.renderIntoDocument(instance);
|
||||
instance = renderIntoDocument(instance);
|
||||
expect(instance.state.occupation).toEqual('clown');
|
||||
});
|
||||
|
||||
it('renders based on context getInitialState', () => {
|
||||
var Foo = createReactClass({
|
||||
contextTypes: {
|
||||
className: React.PropTypes.string,
|
||||
className: PropTypes.string,
|
||||
},
|
||||
getInitialState() {
|
||||
return {className: this.context.className};
|
||||
@@ -300,7 +356,7 @@ describe('ReactClass-spec', () => {
|
||||
|
||||
var Outer = createReactClass({
|
||||
childContextTypes: {
|
||||
className: React.PropTypes.string,
|
||||
className: PropTypes.string,
|
||||
},
|
||||
getChildContext() {
|
||||
return {className: 'foo'};
|
||||
@@ -329,9 +385,9 @@ describe('ReactClass-spec', () => {
|
||||
});
|
||||
var instance = <Component />;
|
||||
expect(function() {
|
||||
instance = ReactTestUtils.renderIntoDocument(instance);
|
||||
instance = renderIntoDocument(instance);
|
||||
}).toThrowError(
|
||||
'Component.getInitialState(): must return an object or null',
|
||||
'Component.getInitialState(): must return an object or null'
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -345,9 +401,7 @@ describe('ReactClass-spec', () => {
|
||||
return <span />;
|
||||
},
|
||||
});
|
||||
expect(() =>
|
||||
ReactTestUtils.renderIntoDocument(<Component />),
|
||||
).not.toThrow();
|
||||
expect(() => renderIntoDocument(<Component />)).not.toThrow();
|
||||
});
|
||||
|
||||
it('should throw when using legacy factories', () => {
|
||||
@@ -359,10 +413,10 @@ describe('ReactClass-spec', () => {
|
||||
});
|
||||
|
||||
expect(() => Component()).toThrow();
|
||||
expect(console.error.calls.count()).toBe(1);
|
||||
expect(console.error.calls.argsFor(0)[0]).toBe(
|
||||
expectDev(console.error.calls.count()).toBe(1);
|
||||
expectDev(console.error.calls.argsFor(0)[0]).toBe(
|
||||
'Warning: Something is calling a React component directly. Use a ' +
|
||||
'factory or JSX instead. See: https://fb.me/react-legacyfactory',
|
||||
'factory or JSX instead. See: https://fb.me/react-legacyfactory'
|
||||
);
|
||||
});
|
||||
|
||||
@@ -378,7 +432,7 @@ describe('ReactClass-spec', () => {
|
||||
},
|
||||
});
|
||||
|
||||
var instance = ReactTestUtils.renderIntoDocument(<Component />);
|
||||
var instance = renderIntoDocument(<Component />);
|
||||
instance.replaceState({step: 1}, () => {
|
||||
ops.push('Callback: ' + instance.state.step);
|
||||
});
|
||||
@@ -462,11 +516,11 @@ describe('ReactClass-spec', () => {
|
||||
'after unmount: false',
|
||||
]);
|
||||
|
||||
expect(console.error.calls.count()).toBe(1);
|
||||
expect(console.error.calls.argsFor(0)[0]).toEqual(
|
||||
expectDev(console.error.calls.count()).toBe(1);
|
||||
expectDev(console.error.calls.argsFor(0)[0]).toEqual(
|
||||
'Warning: MyComponent: isMounted is deprecated. Instead, make sure to ' +
|
||||
'clean up subscriptions and pending requests in componentWillUnmount ' +
|
||||
'to prevent memory leaks.',
|
||||
'to prevent memory leaks.'
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* Copyright 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @emails react-core
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const webpack = require('webpack');
|
||||
|
||||
let __DEV__;
|
||||
switch (process.env.NODE_ENV) {
|
||||
case 'development':
|
||||
__DEV__ = true;
|
||||
break;
|
||||
case 'production':
|
||||
__DEV__ = false;
|
||||
break;
|
||||
default:
|
||||
throw new Error('Unknown environment.');
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
entry: './index',
|
||||
output: {
|
||||
library: 'createReactClass',
|
||||
libraryTarget: 'umd',
|
||||
filename: __DEV__ ? 'create-react-class.js' : 'create-react-class.min.js',
|
||||
},
|
||||
externals: {
|
||||
react: {
|
||||
root: 'React',
|
||||
commonjs2: 'react',
|
||||
commonjs: 'react',
|
||||
amd: 'react',
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
'process.env.NODE_ENV': __DEV__ ? '"development"' : '"production"',
|
||||
}),
|
||||
].concat(
|
||||
__DEV__
|
||||
? []
|
||||
: [
|
||||
new webpack.optimize.UglifyJsPlugin({
|
||||
compress: {
|
||||
warnings: false,
|
||||
},
|
||||
output: {
|
||||
comments: false,
|
||||
},
|
||||
}),
|
||||
]
|
||||
),
|
||||
};
|
||||
File diff suppressed because it is too large.
Load diff
+16
-16
@@ -65,7 +65,7 @@ function traverseAllChildrenImpl(
|
||||
children,
|
||||
nameSoFar,
|
||||
callback,
|
||||
traverseContext,
|
||||
traverseContext
|
||||
) {
|
||||
var type = typeof children;
|
||||
|
||||
@@ -87,7 +87,7 @@ function traverseAllChildrenImpl(
|
||||
children,
|
||||
// If it's the only child, treat the name as if it was wrapped in an array
|
||||
// so that it's consistent if the number of children grows.
|
||||
nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar,
|
||||
nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
@@ -105,7 +105,7 @@ function traverseAllChildrenImpl(
|
||||
child,
|
||||
nextName,
|
||||
callback,
|
||||
traverseContext,
|
||||
traverseContext
|
||||
);
|
||||
}
|
||||
} else {
|
||||
@@ -118,7 +118,7 @@ function traverseAllChildrenImpl(
|
||||
didWarnAboutMaps,
|
||||
'Using Maps as children is unsupported and will likely yield ' +
|
||||
'unexpected results. Convert it to a sequence/iterable of keyed ' +
|
||||
'ReactElements instead.',
|
||||
'ReactElements instead.'
|
||||
);
|
||||
didWarnAboutMaps = true;
|
||||
}
|
||||
@@ -134,7 +134,7 @@ function traverseAllChildrenImpl(
|
||||
child,
|
||||
nextName,
|
||||
callback,
|
||||
traverseContext,
|
||||
traverseContext
|
||||
);
|
||||
}
|
||||
} else if (type === 'object') {
|
||||
@@ -152,7 +152,7 @@ function traverseAllChildrenImpl(
|
||||
childrenString === '[object Object]'
|
||||
? 'object with keys {' + Object.keys(children).join(', ') + '}'
|
||||
: childrenString,
|
||||
addendum,
|
||||
addendum
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -177,7 +177,7 @@ function cloneAndReplaceKey(oldElement, newKey) {
|
||||
return React.cloneElement(
|
||||
oldElement,
|
||||
{key: newKey},
|
||||
oldElement.props !== undefined ? oldElement.props.children : undefined,
|
||||
oldElement.props !== undefined ? oldElement.props.children : undefined
|
||||
);
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ var standardReleaser = function standardReleaser(instance) {
|
||||
var Klass = this;
|
||||
invariant(
|
||||
instance instanceof Klass,
|
||||
'Trying to release an instance into a pool of a different type.',
|
||||
'Trying to release an instance into a pool of a different type.'
|
||||
);
|
||||
instance.destructor();
|
||||
if (Klass.instancePool.length < Klass.poolSize) {
|
||||
@@ -259,7 +259,7 @@ function mapSingleChildIntoContext(bookKeeping, child, childKey) {
|
||||
mappedChild,
|
||||
result,
|
||||
childKey,
|
||||
emptyFunction.thatReturnsArgument,
|
||||
emptyFunction.thatReturnsArgument
|
||||
);
|
||||
} else if (mappedChild != null) {
|
||||
if (React.isValidElement(mappedChild)) {
|
||||
@@ -271,7 +271,7 @@ function mapSingleChildIntoContext(bookKeeping, child, childKey) {
|
||||
(mappedChild.key && (!child || child.key !== mappedChild.key)
|
||||
? escapeUserProvidedKey(mappedChild.key) + '/'
|
||||
: '') +
|
||||
childKey,
|
||||
childKey
|
||||
);
|
||||
}
|
||||
result.push(mappedChild);
|
||||
@@ -287,7 +287,7 @@ function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
|
||||
array,
|
||||
escapedPrefix,
|
||||
func,
|
||||
context,
|
||||
context
|
||||
);
|
||||
traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
|
||||
MapBookKeeping.release(traverseContext);
|
||||
@@ -302,7 +302,7 @@ function createReactFragment(object) {
|
||||
warning(
|
||||
false,
|
||||
'React.addons.createFragment only accepts a single object. Got: %s',
|
||||
object,
|
||||
object
|
||||
);
|
||||
return object;
|
||||
}
|
||||
@@ -310,7 +310,7 @@ function createReactFragment(object) {
|
||||
warning(
|
||||
false,
|
||||
'React.addons.createFragment does not accept a ReactElement ' +
|
||||
'without a wrapper object.',
|
||||
'without a wrapper object.'
|
||||
);
|
||||
return object;
|
||||
}
|
||||
@@ -318,7 +318,7 @@ function createReactFragment(object) {
|
||||
invariant(
|
||||
object.nodeType !== 1,
|
||||
'React.addons.createFragment(...): Encountered an invalid child; DOM ' +
|
||||
'elements are not valid children of React components.',
|
||||
'elements are not valid children of React components.'
|
||||
);
|
||||
|
||||
var result = [];
|
||||
@@ -329,7 +329,7 @@ function createReactFragment(object) {
|
||||
warning(
|
||||
false,
|
||||
'React.addons.createFragment(...): Child objects should have ' +
|
||||
'non-numeric keys so ordering is preserved.',
|
||||
'non-numeric keys so ordering is preserved.'
|
||||
);
|
||||
warnedAboutNumeric = true;
|
||||
}
|
||||
@@ -338,7 +338,7 @@ function createReactFragment(object) {
|
||||
object[key],
|
||||
result,
|
||||
key,
|
||||
emptyFunction.thatReturnsArgument,
|
||||
emptyFunction.thatReturnsArgument
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
"react-addons-create-fragment.min.js"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "jest"
|
||||
"test": "jest",
|
||||
"prepublish": "npm test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jest": "^19.0.2",
|
||||
|
||||
+4
-4
@@ -52,7 +52,7 @@ describe('createReactFragment', () => {
|
||||
|
||||
expectDev(console.error.calls.count()).toBe(1);
|
||||
expectDev(console.error.calls.argsFor(0)[0]).toContain(
|
||||
'Child objects should have non-numeric keys so ordering is preserved.',
|
||||
'Child objects should have non-numeric keys so ordering is preserved.'
|
||||
);
|
||||
});
|
||||
|
||||
@@ -61,7 +61,7 @@ describe('createReactFragment', () => {
|
||||
createReactFragment(null);
|
||||
expectDev(console.error.calls.count()).toBe(1);
|
||||
expectDev(console.error.calls.argsFor(0)[0]).toContain(
|
||||
'React.addons.createFragment only accepts a single object.',
|
||||
'React.addons.createFragment only accepts a single object.'
|
||||
);
|
||||
});
|
||||
|
||||
@@ -70,7 +70,7 @@ describe('createReactFragment', () => {
|
||||
createReactFragment([]);
|
||||
expectDev(console.error.calls.count()).toBe(1);
|
||||
expectDev(console.error.calls.argsFor(0)[0]).toContain(
|
||||
'React.addons.createFragment only accepts a single object.',
|
||||
'React.addons.createFragment only accepts a single object.'
|
||||
);
|
||||
});
|
||||
|
||||
@@ -80,7 +80,7 @@ describe('createReactFragment', () => {
|
||||
expectDev(console.error.calls.count()).toBe(1);
|
||||
expectDev(console.error.calls.argsFor(0)[0]).toContain(
|
||||
'React.addons.createFragment does not accept a ReactElement without a ' +
|
||||
'wrapper object.',
|
||||
'wrapper object.'
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -8,6 +8,9 @@
|
||||
"react-addon"
|
||||
],
|
||||
"license": "BSD-3-Clause",
|
||||
"scripts": {
|
||||
"prepublish": ":"
|
||||
},
|
||||
"dependencies": {
|
||||
"react-transition-group": "^1.2.0"
|
||||
},
|
||||
|
||||
+1
-1
@@ -150,7 +150,7 @@ var LinkedStateMixin = {
|
||||
linkState: function(key) {
|
||||
return new ReactLink(
|
||||
this.state[key],
|
||||
ReactStateSetters.createStateKeySetter(this, key),
|
||||
ReactStateSetters.createStateKeySetter(this, key)
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
"object-assign": "^4.1.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "jest"
|
||||
"test": "jest",
|
||||
"prepublish": "npm test"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
|
||||
+2
-2
@@ -56,7 +56,7 @@ describe('LinkedStateMixin', () => {
|
||||
});
|
||||
|
||||
const instance = ReactTestUtils.renderIntoDocument(
|
||||
React.createElement(WithLink),
|
||||
React.createElement(WithLink)
|
||||
);
|
||||
|
||||
expect(instance.state.message).toBe('Hello!');
|
||||
@@ -87,7 +87,7 @@ describe('LinkedStateMixin', () => {
|
||||
});
|
||||
|
||||
const instance = ReactTestUtils.renderIntoDocument(
|
||||
React.createElement(WithoutLink),
|
||||
React.createElement(WithoutLink)
|
||||
);
|
||||
|
||||
expect(instance.state.message).toBe('Hello!');
|
||||
|
||||
@@ -21,7 +21,8 @@
|
||||
"react-addons-pure-render-mixin.min.js"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "jest"
|
||||
"test": "jest",
|
||||
"prepublish": "npm test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jest": "^19.0.2",
|
||||
|
||||
+2
-2
@@ -85,7 +85,7 @@ describe('createReactFragment', () => {
|
||||
});
|
||||
|
||||
var instance = ReactTestUtils.renderIntoDocument(
|
||||
React.createElement(PlasticWrap),
|
||||
React.createElement(PlasticWrap)
|
||||
);
|
||||
expect(renderCalls).toBe(1);
|
||||
|
||||
@@ -135,7 +135,7 @@ describe('createReactFragment', () => {
|
||||
});
|
||||
|
||||
var instance = ReactTestUtils.renderIntoDocument(
|
||||
React.createElement(Component),
|
||||
React.createElement(Component)
|
||||
);
|
||||
expect(renderCalls).toBe(1);
|
||||
|
||||
|
||||
@@ -21,7 +21,8 @@
|
||||
"react-addons-shallow-compare.min.js"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "jest"
|
||||
"test": "jest",
|
||||
"prepublish": "npm test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jest": "^19.0.2",
|
||||
|
||||
+5
-5
@@ -63,7 +63,7 @@ describe('shallowCompare', () => {
|
||||
text = ['porcini'];
|
||||
component = ReactDOM.render(
|
||||
React.createElement(Component, {text}),
|
||||
container,
|
||||
container
|
||||
);
|
||||
expect(container.textContent).toBe('porcini');
|
||||
expect(renders).toBe(1);
|
||||
@@ -71,7 +71,7 @@ describe('shallowCompare', () => {
|
||||
text = ['morel'];
|
||||
component = ReactDOM.render(
|
||||
React.createElement(Component, {text}),
|
||||
container,
|
||||
container
|
||||
);
|
||||
expect(container.textContent).toBe('morel');
|
||||
expect(renders).toBe(2);
|
||||
@@ -79,7 +79,7 @@ describe('shallowCompare', () => {
|
||||
text[0] = 'portobello';
|
||||
component = ReactDOM.render(
|
||||
React.createElement(Component, {text}),
|
||||
container,
|
||||
container
|
||||
);
|
||||
expect(container.textContent).toBe('morel');
|
||||
expect(renders).toBe(2);
|
||||
@@ -166,7 +166,7 @@ describe('shallowCompare', () => {
|
||||
});
|
||||
|
||||
var instance = ReactTestUtils.renderIntoDocument(
|
||||
React.createElement(PlasticWrap),
|
||||
React.createElement(PlasticWrap)
|
||||
);
|
||||
expect(renderCalls).toBe(1);
|
||||
|
||||
@@ -218,7 +218,7 @@ describe('shallowCompare', () => {
|
||||
});
|
||||
|
||||
var instance = ReactTestUtils.renderIntoDocument(
|
||||
React.createElement(Component),
|
||||
React.createElement(Component)
|
||||
);
|
||||
expect(renderCalls).toBe(1);
|
||||
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ var warning = require('fbjs/lib/warning');
|
||||
warning(
|
||||
false,
|
||||
'ReactTestUtils has been moved to react-dom/test-utils. ' +
|
||||
'Update references to remove this warning.',
|
||||
'Update references to remove this warning.'
|
||||
);
|
||||
|
||||
module.exports = require('react-dom/lib/ReactTestUtils');
|
||||
@@ -15,6 +15,9 @@
|
||||
"peerDependencies": {
|
||||
"react-dom": "^15.4.2"
|
||||
},
|
||||
"scripts": {
|
||||
"prepublish": ":"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jest": "^19.0.2",
|
||||
"react": "^15.4.2",
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ describe('ReactTestUtils', function() {
|
||||
it('should warn on include', function() {
|
||||
expect(console.error).toHaveBeenCalledWith(
|
||||
'Warning: ReactTestUtils has been moved to react-dom/test-utils. ' +
|
||||
'Update references to remove this warning.',
|
||||
'Update references to remove this warning.'
|
||||
);
|
||||
});
|
||||
|
||||
@@ -41,7 +41,7 @@ describe('ReactTestUtils', function() {
|
||||
}
|
||||
|
||||
const instance = ReactTestUtils.renderIntoDocument(
|
||||
<MyComponent baz="abc" />,
|
||||
<MyComponent baz="abc" />
|
||||
);
|
||||
|
||||
expect(instance.state.bar).toBe(123);
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
"peerDependencies": {
|
||||
"react": "^15.4.2"
|
||||
},
|
||||
"scripts": {
|
||||
"prepublish": ":"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"PATENTS",
|
||||
|
||||
Vendored
+10
-10
@@ -50,7 +50,7 @@ function invariantArrayCase(value, spec, command) {
|
||||
Array.isArray(value),
|
||||
'update(): expected target of %s to be an array; got %s.',
|
||||
command,
|
||||
value,
|
||||
value
|
||||
);
|
||||
var specValue = spec[command];
|
||||
invariant(
|
||||
@@ -58,7 +58,7 @@ function invariantArrayCase(value, spec, command) {
|
||||
'update(): expected spec of %s to be an array; got %s. ' +
|
||||
'Did you forget to wrap your parameter in an array?',
|
||||
command,
|
||||
specValue,
|
||||
specValue
|
||||
);
|
||||
}
|
||||
|
||||
@@ -72,14 +72,14 @@ function update(value, spec) {
|
||||
'update(): You provided a key path to update() that did not contain one ' +
|
||||
'of %s. Did you forget to include {%s: ...}?',
|
||||
ALL_COMMANDS_LIST.join(', '),
|
||||
COMMAND_SET,
|
||||
COMMAND_SET
|
||||
);
|
||||
|
||||
if (hasOwnProperty.call(spec, COMMAND_SET)) {
|
||||
invariant(
|
||||
Object.keys(spec).length === 1,
|
||||
'Cannot have more than one key in an object with %s',
|
||||
COMMAND_SET,
|
||||
COMMAND_SET
|
||||
);
|
||||
|
||||
return spec[COMMAND_SET];
|
||||
@@ -93,13 +93,13 @@ function update(value, spec) {
|
||||
mergeObj && typeof mergeObj === 'object',
|
||||
"update(): %s expects a spec of type 'object'; got %s",
|
||||
COMMAND_MERGE,
|
||||
mergeObj,
|
||||
mergeObj
|
||||
);
|
||||
invariant(
|
||||
nextValue && typeof nextValue === 'object',
|
||||
"update(): %s expects a target of type 'object'; got %s",
|
||||
COMMAND_MERGE,
|
||||
nextValue,
|
||||
nextValue
|
||||
);
|
||||
_assign(nextValue, spec[COMMAND_MERGE]);
|
||||
}
|
||||
@@ -123,14 +123,14 @@ function update(value, spec) {
|
||||
Array.isArray(value),
|
||||
'Expected %s target to be an array; got %s',
|
||||
COMMAND_SPLICE,
|
||||
value,
|
||||
value
|
||||
);
|
||||
invariant(
|
||||
Array.isArray(spec[COMMAND_SPLICE]),
|
||||
'update(): expected spec of %s to be an array of arrays; got %s. ' +
|
||||
'Did you forget to wrap your parameters in an array?',
|
||||
COMMAND_SPLICE,
|
||||
spec[COMMAND_SPLICE],
|
||||
spec[COMMAND_SPLICE]
|
||||
);
|
||||
spec[COMMAND_SPLICE].forEach(function(args) {
|
||||
invariant(
|
||||
@@ -138,7 +138,7 @@ function update(value, spec) {
|
||||
'update(): expected spec of %s to be an array of arrays; got %s. ' +
|
||||
'Did you forget to wrap your parameters in an array?',
|
||||
COMMAND_SPLICE,
|
||||
spec[COMMAND_SPLICE],
|
||||
spec[COMMAND_SPLICE]
|
||||
);
|
||||
nextValue.splice.apply(nextValue, args);
|
||||
});
|
||||
@@ -149,7 +149,7 @@ function update(value, spec) {
|
||||
typeof spec[COMMAND_APPLY] === 'function',
|
||||
'update(): expected spec of %s to be a function; got %s.',
|
||||
COMMAND_APPLY,
|
||||
spec[COMMAND_APPLY],
|
||||
spec[COMMAND_APPLY]
|
||||
);
|
||||
nextValue = spec[COMMAND_APPLY](nextValue);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
"jest": "^19.0.2"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "jest"
|
||||
"test": "jest",
|
||||
"prepublish": "npm test"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
|
||||
Vendored
+5
-5
@@ -17,7 +17,7 @@ function _assertSingleLink(inputProps) {
|
||||
invariant(
|
||||
inputProps.checkedLink == null || inputProps.valueLink == null,
|
||||
'Cannot provide a checkedLink and a valueLink. If you want to use ' +
|
||||
"checkedLink, you probably don't want to use valueLink and vice versa.",
|
||||
"checkedLink, you probably don't want to use valueLink and vice versa."
|
||||
);
|
||||
}
|
||||
function _assertValueLink(inputProps) {
|
||||
@@ -25,7 +25,7 @@ function _assertValueLink(inputProps) {
|
||||
invariant(
|
||||
inputProps.value == null && inputProps.onChange == null,
|
||||
'Cannot provide a valueLink and a value or onChange event. If you want ' +
|
||||
"to use value or onChange, you probably don't want to use valueLink.",
|
||||
"to use value or onChange, you probably don't want to use valueLink."
|
||||
);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ function _assertCheckedLink(inputProps) {
|
||||
inputProps.checked == null && inputProps.onChange == null,
|
||||
'Cannot provide a checkedLink and a checked property or onChange event. ' +
|
||||
"If you want to use checked or onChange, you probably don't want to " +
|
||||
'use checkedLink',
|
||||
'use checkedLink'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ function _classCallCheck(instance, Constructor) {
|
||||
function _possibleConstructorReturn(self, call) {
|
||||
if (!self) {
|
||||
throw new ReferenceError(
|
||||
"this hasn't been initialised - super() hasn't been called",
|
||||
"this hasn't been initialised - super() hasn't been called"
|
||||
);
|
||||
}
|
||||
return call && (typeof call === 'object' || typeof call === 'function')
|
||||
@@ -107,7 +107,7 @@ function _inherits(subClass, superClass) {
|
||||
if (typeof superClass !== 'function' && superClass !== null) {
|
||||
throw new TypeError(
|
||||
'Super expression must either be null or a function, not ' +
|
||||
typeof superClass,
|
||||
typeof superClass
|
||||
);
|
||||
}
|
||||
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
"description": "LinkedInput supports the ReactLink semantics",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "jest"
|
||||
"test": "jest",
|
||||
"prepublish": "npm test"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
Vendored
+2
-2
@@ -49,7 +49,7 @@ describe('LinkedStateMixin', function() {
|
||||
value: 'foo',
|
||||
onChange: noop,
|
||||
}),
|
||||
container,
|
||||
container
|
||||
);
|
||||
const input = ReactDOM.findDOMNode(component);
|
||||
expect(input.value).toBe('foo');
|
||||
@@ -58,7 +58,7 @@ describe('LinkedStateMixin', function() {
|
||||
valueLink: {value: 'boo'},
|
||||
requestChange: noop,
|
||||
}),
|
||||
container,
|
||||
container
|
||||
);
|
||||
expect(input.value).toBe('boo');
|
||||
});
|
||||
|
||||
+12
-12
@@ -2,22 +2,22 @@ var fs = require('fs');
|
||||
var path = require('path');
|
||||
var spawnSync = require('child_process').spawnSync;
|
||||
|
||||
function runNpmCommand(dir, args) {
|
||||
const result = spawnSync('npm', args, {
|
||||
cwd: path.join(__dirname, dir),
|
||||
stdio: 'inherit',
|
||||
});
|
||||
if (result.status !== 0) {
|
||||
process.exit('npm test exited with non-zero code.');
|
||||
}
|
||||
}
|
||||
|
||||
fs
|
||||
.readdirSync(__dirname)
|
||||
.filter(file => {
|
||||
return fs.statSync(path.join(__dirname, file)).isDirectory();
|
||||
})
|
||||
.forEach(dir => {
|
||||
spawnSync('npm', ['install'], {
|
||||
cwd: path.join(__dirname, dir),
|
||||
stdio: 'inherit',
|
||||
});
|
||||
const result = spawnSync('npm', ['test'], {
|
||||
cwd: path.join(__dirname, dir),
|
||||
stdio: 'inherit',
|
||||
});
|
||||
if (result.status !== 0) {
|
||||
process.exit('npm test exited with non-zero code.');
|
||||
}
|
||||
// TODO: also test that build succeeds
|
||||
runNpmCommand(dir, ['install']);
|
||||
runNpmCommand(dir, ['run', 'prepublish']);
|
||||
});
|
||||
@@ -39,6 +39,9 @@ const config = {
|
||||
ignore: [
|
||||
'**/node_modules/**',
|
||||
],
|
||||
options: {
|
||||
'trailing-comma': 'es5',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user