Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
81155 views
1
/**
2
* Copyright 2013-2014, Facebook, Inc.
3
* All rights reserved.
4
*
5
* This source code is licensed under the BSD-style license found in the
6
* LICENSE file in the root directory of this source tree. An additional grant
7
* of patent rights can be found in the PATENTS file in the same directory.
8
*
9
* @emails react-core
10
*/
11
12
"use strict";
13
14
var mocks = require('mocks');
15
16
var React;
17
var ReactTestUtils;
18
var reactComponentExpect;
19
20
describe('ReactCompositeComponent-spec', function() {
21
22
beforeEach(function() {
23
React = require('React');
24
ReactTestUtils = require('ReactTestUtils');
25
reactComponentExpect = require('reactComponentExpect');
26
});
27
28
it('should throw when `render` is not specified', function() {
29
expect(function() {
30
React.createClass({});
31
}).toThrow(
32
'Invariant Violation: createClass(...): Class specification must ' +
33
'implement a `render` method.'
34
);
35
});
36
37
it('should copy `displayName` onto the Constructor', function() {
38
var TestComponent = React.createClass({
39
render: function() {
40
return <div />;
41
}
42
});
43
44
expect(TestComponent.type.displayName)
45
.toBe('TestComponent');
46
});
47
48
it('should copy prop types onto the Constructor', function() {
49
var propValidator = mocks.getMockFunction();
50
var TestComponent = React.createClass({
51
propTypes: {
52
value: propValidator
53
},
54
render: function() {
55
return <div />;
56
}
57
});
58
59
expect(TestComponent.type.propTypes).toBeDefined();
60
expect(TestComponent.type.propTypes.value)
61
.toBe(propValidator);
62
});
63
});
64
65