[test] Add tests for mutating a global
The error is thrown correctly but the error message is incorrect.
Sathya Gunasekaran committed
Nov 15, 2023 at 17:03 UTC
392a4fd9da8ff45f8cd050a17d4a01d89fc0c25f
4 files changed
+54
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.mutate-property-from-global.expect.md
new
+21
@@ -0,0 +1,21 @@
1
+
2
+## Input
3
+
4
+```javascript
5
+let wat = {};
6
+
7
+function Foo() {
8
+ delete wat.foo;
9
+ return wat;
10
+}
11
+
12
+```
13
+
14
+
15
+## Error
16
+
17
+```
18
+[ReactForget] InvalidReact: This mutates a variable after it was passed to React, which means that React cannot observe changes to it (4:4)
19
+```
20
+
21
+
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.mutate-property-from-global.js
new
+6
@@ -0,0 +1,6 @@
1
+let wat = {};
2
+
3
+function Foo() {
4
+ delete wat.foo;
5
+ return wat;
6
+}
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.store-property-in-global.expect.md
new
+21
@@ -0,0 +1,21 @@
1
+
2
+## Input
3
+
4
+```javascript
5
+let wat = {};
6
+
7
+function Foo() {
8
+ wat.test = 1;
9
+ return wat;
10
+}
11
+
12
+```
13
+
14
+
15
+## Error
16
+
17
+```
18
+[ReactForget] InvalidReact: This mutates a variable after it was passed to React, which means that React cannot observe changes to it (4:4)
19
+```
20
+
21
+
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.store-property-in-global.js
new
+6
@@ -0,0 +1,6 @@
1
+let wat = {};
2
+
3
+function Foo() {
4
+ wat.test = 1;
5
+ return wat;
6
+}