@samitouri / QOS-React-2 / commits / 9b36b04d75

Drop internal uses of .type on the class

Sebastian Markbage committed Oct 24, 2014 at 08:09 UTC 9b36b04d75b59a4e0d155735b9ea60ee5fe00afb
6 files changed +16 -26
src/core/ReactNativeComponent.js
+1 -1
@@ -58,7 +58,7 @@ function createInstanceForTag(tag, props, parentType) {
58 return new genericComponentClass(tag, props);
59 }
60 // Unwrap legacy factories
61 - return new componentClass.type(props);
61 + return new componentClass(props);
62 }
63
64 var ReactNativeComponent = {
src/core/__tests__/ReactCompositeComponent-test.js
+2 -2
@@ -1237,8 +1237,8 @@ describe('ReactCompositeComponent', function() {
1237 expect(Component.ghi).toBe(null);
1238 expect(instance.constructor.jkl).toBe('mno');
1239 expect(Component.jkl).toBe('mno');
1240 - expect(instance.constructor.pqr()).toBe(Component.type);
1241 - expect(Component.pqr()).toBe(Component.type);
1240 + expect(instance.constructor.pqr()).toBe(Component);
1241 + expect(Component.pqr()).toBe(Component);
1242 });
1243
1244 it('should throw if a reserved property is in statics', function() {
src/core/__tests__/ReactCompositeComponentMixin-test.js
+5 -5
@@ -152,8 +152,8 @@ describe('ReactCompositeComponent-mixin', function() {
152 });
153
154 it('should validate prop types via mixins', function() {
155 - expect(TestComponent.type.propTypes).toBeDefined();
156 - expect(TestComponent.type.propTypes.value)
155 + expect(TestComponent.propTypes).toBeDefined();
156 + expect(TestComponent.propTypes.value)
157 .toBe(mixinPropValidator);
158 });
159
@@ -161,11 +161,11 @@ describe('ReactCompositeComponent-mixin', function() {
161 // Sanity check...
162 expect(componentPropValidator).toNotBe(mixinPropValidator);
163 // Actually check...
164 - expect(TestComponentWithPropTypes.type.propTypes)
164 + expect(TestComponentWithPropTypes.propTypes)
165 .toBeDefined();
166 - expect(TestComponentWithPropTypes.type.propTypes.value)
166 + expect(TestComponentWithPropTypes.propTypes.value)
167 .toNotBe(mixinPropValidator);
168 - expect(TestComponentWithPropTypes.type.propTypes.value)
168 + expect(TestComponentWithPropTypes.propTypes.value)
169 .toBe(componentPropValidator);
170 });
171 });
src/core/__tests__/ReactCompositeComponentSpec-test.js
+3 -3
@@ -41,7 +41,7 @@ describe('ReactCompositeComponent-spec', function() {
41 }
42 });
43
44 - expect(TestComponent.type.displayName)
44 + expect(TestComponent.displayName)
45 .toBe('TestComponent');
46 });
47
@@ -56,8 +56,8 @@ describe('ReactCompositeComponent-spec', function() {
56 }
57 });
58
59 - expect(TestComponent.type.propTypes).toBeDefined();
60 - expect(TestComponent.type.propTypes.value)
59 + expect(TestComponent.propTypes).toBeDefined();
60 + expect(TestComponent.propTypes.value)
61 .toBe(propValidator);
62 });
63 });
src/core/__tests__/ReactElement-test.js
+1 -8
@@ -26,7 +26,7 @@ describe('ReactElement', function() {
26 ComponentFactory = React.createClass({
27 render: function() { return <div />; }
28 });
29 - ComponentClass = ComponentFactory.type;
29 + ComponentClass = ComponentFactory;
30 });
31
32 it('returns a complete element according to spec', function() {
@@ -338,13 +338,6 @@ describe('ReactElement', function() {
338 expect(ReactElement.isValidElement(Component)).toEqual(false);
339 });
340
341 - it('should expose the underlying class from a legacy factory', function() {
342 - var Legacy = React.createClass({ render: function() { } });
343 - var factory = React.createFactory(Legacy);
344 - expect(factory.type).toBe(Legacy.type);
345 - expect(factory().type).toBe(Legacy.type);
346 - });
347 -
341 it('allows the use of PropTypes validators in statics', function() {
342 var Component = React.createClass({
343 render: () => null,
src/test/reactComponentExpect.js
+4 -7
@@ -97,12 +97,9 @@ assign(reactComponentExpect.prototype, {
97
98 // Matchers ------------------------------------------------------------------
99
100 - toBeComponentOfType: function(convenienceConstructor) {
101 - var type = typeof convenienceConstructor === 'string' ?
102 - convenienceConstructor :
103 - convenienceConstructor.type;
100 + toBeComponentOfType: function(constructor) {
101 expect(
105 - this.instance()._currentElement.type === type
102 + this.instance()._currentElement.type === constructor
103 ).toBe(true);
104 return this;
105 },
@@ -119,10 +116,10 @@ assign(reactComponentExpect.prototype, {
116 return this;
117 },
118
122 - toBeCompositeComponentWithType: function(convenienceConstructor) {
119 + toBeCompositeComponentWithType: function(constructor) {
120 this.toBeCompositeComponent();
121 expect(
125 - this.instance()._currentElement.type === convenienceConstructor.type
122 + this.instance()._currentElement.type === constructor
123 ).toBe(true);
124 return this;
125 },