Skip to content

Commit c8eb10d

Browse files
committed
Add a getter test to es-class-assign-property-variable
I'm not entirely sure if this is the desired result, but I think it maybe is, since anything could be using the getter.
1 parent 8ee80d1 commit c8eb10d

File tree

5 files changed

+84
-0
lines changed

5 files changed

+84
-0
lines changed

test/fixtures/es-class-assign-property-variable/actual.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,13 @@ class Foo extends React.Component {
77
}
88

99
Foo.propTypes = propTypes;
10+
11+
class Getter extends React.Component {
12+
get foo() {
13+
return { foo: PropTypes.string };
14+
}
15+
16+
render() {}
17+
}
18+
19+
Getter.propTypes = Getter.foo;

test/fixtures/es-class-assign-property-variable/expected-remove-es5.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,27 @@ function (_React$Component) {
1616
}]);
1717
return Foo;
1818
}(React.Component);
19+
20+
var Getter =
21+
/*#__PURE__*/
22+
function (_React$Component2) {
23+
babelHelpers.inherits(Getter, _React$Component2);
24+
25+
function Getter() {
26+
babelHelpers.classCallCheck(this, Getter);
27+
return babelHelpers.possibleConstructorReturn(this, (Getter.__proto__ || Object.getPrototypeOf(Getter)).apply(this, arguments));
28+
}
29+
30+
babelHelpers.createClass(Getter, [{
31+
key: "render",
32+
value: function render() {}
33+
}, {
34+
key: "foo",
35+
get: function get() {
36+
return {
37+
foo: PropTypes.string
38+
};
39+
}
40+
}]);
41+
return Getter;
42+
}(React.Component);

test/fixtures/es-class-assign-property-variable/expected-remove-es6.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,14 @@ class Foo extends React.Component {
22
render() {}
33

44
}
5+
6+
class Getter extends React.Component {
7+
get foo() {
8+
return {
9+
foo: PropTypes.string
10+
};
11+
}
12+
13+
render() {}
14+
15+
}

test/fixtures/es-class-assign-property-variable/expected-wrap-es5.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,29 @@ function (_React$Component) {
2222
}(React.Component);
2323

2424
Foo.propTypes = process.env.NODE_ENV !== "production" ? propTypes : {};
25+
26+
var Getter =
27+
/*#__PURE__*/
28+
function (_React$Component2) {
29+
babelHelpers.inherits(Getter, _React$Component2);
30+
31+
function Getter() {
32+
babelHelpers.classCallCheck(this, Getter);
33+
return babelHelpers.possibleConstructorReturn(this, (Getter.__proto__ || Object.getPrototypeOf(Getter)).apply(this, arguments));
34+
}
35+
36+
babelHelpers.createClass(Getter, [{
37+
key: "render",
38+
value: function render() {}
39+
}, {
40+
key: "foo",
41+
get: function get() {
42+
return {
43+
foo: PropTypes.string
44+
};
45+
}
46+
}]);
47+
return Getter;
48+
}(React.Component);
49+
50+
Getter.propTypes = process.env.NODE_ENV !== "production" ? Getter.foo : {};

test/fixtures/es-class-assign-property-variable/expected-wrap-es6.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,16 @@ class Foo extends React.Component {
88
}
99

1010
Foo.propTypes = process.env.NODE_ENV !== "production" ? propTypes : {};
11+
12+
class Getter extends React.Component {
13+
get foo() {
14+
return {
15+
foo: PropTypes.string
16+
};
17+
}
18+
19+
render() {}
20+
21+
}
22+
23+
Getter.propTypes = process.env.NODE_ENV !== "production" ? Getter.foo : {};

0 commit comments

Comments
 (0)