Fix react-dislayName-test
[skip ci]
Paul O’Shannessy committed
Jul 11, 2014 at 10:36 UTC
28d94d2dcfdd081b49ecf3febbc04750b108cf94
2 files changed
+13
-151
vendor/fbtransform/transforms/__tests__/react-displayName-test.js
+13
-1
@@ -1,5 +1,17 @@
1
/**
2
- * Copyright 2004-present Facebook. All Rights Reserved.
2
+ * Copyright 2013-2014 Facebook, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
*
16
* @emails jeffmo@fb.com
17
*/
vendor/fbtransform/transforms/__tests__/reactDisplayName-test.js
deleted
-150
@@ -1,150 +0,0 @@
1
-/**
2
- * Copyright 2013-2014 Facebook, Inc.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- *
16
- * @emails javascript@lists.facebook.com
17
- */
18
-"use strict";
19
-
20
-require('mock-modules').autoMockOff();
21
-
22
-var transformAll = require('../../syntax.js').transformAll;
23
-
24
-function transform(source) {
25
- return transformAll(source, {}, ['allocate']);
26
-}
27
-
28
-describe('react displayName jsx', function() {
29
-
30
- it('should only inject displayName if missing', function() {
31
- var code = [
32
- '/** @jsx React.DOM */',
33
- '"use strict";',
34
- 'var Whateva = React.createClass({',
35
- ' displayName: \'Whateva\',',
36
- ' render: function() {',
37
- ' return <div className=\'whateva\'>...whateva.</div>;',
38
- ' }',
39
- '});'
40
- ].join('\n');
41
-
42
- var result = [
43
- '/** @jsx React.DOM */',
44
- '"use strict";',
45
- 'var Whateva = React.createClass({',
46
- ' displayName: \'Whateva\',',
47
- ' render: function() {',
48
- ' return React.DOM.div({className: "whateva"}, "...whateva.");',
49
- ' }',
50
- '});'
51
- ].join('\n');
52
-
53
- expect(transform(code).code).toEqual(result);
54
- });
55
-
56
- it('should inject displayName in simple assignment', () => {
57
- var code = [
58
- '/** @jsx React.DOM */',
59
- 'var Component = React.createClass({',
60
- ' render: function() {',
61
- ' return <div/>;',
62
- ' }',
63
- '});'
64
- ].join('\n');
65
-
66
- var result = [
67
- '/** @jsx React.DOM */',
68
- 'var Component = React.createClass({displayName: \'Component\',',
69
- ' render: function() {',
70
- ' return React.DOM.div(null);',
71
- ' }',
72
- '});'
73
- ].join('\n');
74
-
75
- expect(transform(code).code).toEqual(result);
76
- });
77
-
78
- it('should inject displayName in simple assignment without var', () => {
79
- var code = [
80
- '/** @jsx React.DOM */',
81
- 'var Component;',
82
- 'Component = React.createClass({',
83
- ' render: function() {',
84
- ' return <div/>;',
85
- ' }',
86
- '});'
87
- ].join('\n');
88
-
89
- var result = [
90
- '/** @jsx React.DOM */',
91
- 'var Component;',
92
- 'Component = React.createClass({displayName: \'Component\',',
93
- ' render: function() {',
94
- ' return React.DOM.div(null);',
95
- ' }',
96
- '});'
97
- ].join('\n');
98
-
99
- expect(transform(code).code).toEqual(result);
100
- });
101
-
102
- it('should inject displayName in property assignment', () => {
103
- var code = [
104
- '/** @jsx React.DOM */',
105
- 'exports.Component = React.createClass({',
106
- ' render: function() {',
107
- ' return <div/>;',
108
- ' }',
109
- '});'
110
- ].join('\n');
111
-
112
- var result = [
113
- '/** @jsx React.DOM */',
114
- 'exports.Component = React.createClass({displayName: \'Component\',',
115
- ' render: function() {',
116
- ' return React.DOM.div(null);',
117
- ' }',
118
- '});'
119
- ].join('\n');
120
-
121
- expect(transform(code).code).toEqual(result);
122
- });
123
-
124
- it('should inject displayName in object declaration', () => {
125
- var code = [
126
- '/** @jsx React.DOM */',
127
- 'exports = {',
128
- ' Component: React.createClass({',
129
- ' render: function() {',
130
- ' return <div/>;',
131
- ' }',
132
- ' })',
133
- '};'
134
- ].join('\n');
135
-
136
- var result = [
137
- '/** @jsx React.DOM */',
138
- 'exports = {',
139
- ' Component: React.createClass({displayName: \'Component\',',
140
- ' render: function() {',
141
- ' return React.DOM.div(null);',
142
- ' }',
143
- ' })',
144
- '};'
145
- ].join('\n');
146
-
147
- expect(transform(code).code).toEqual(result);
148
- });
149
-
150
-});