[test] Add tests for mutating a global

The error is thrown correctly but the error message is incorrect.
This commit is contained in:
Sathya Gunasekaran
2023-11-15 17:03:51 +00:00
parent 306fe03e78
commit 392a4fd9da
4 changed files with 54 additions and 0 deletions
@@ -0,0 +1,21 @@
## Input
```javascript
let wat = {};
function Foo() {
delete wat.foo;
return wat;
}
```
## Error
```
[ReactForget] InvalidReact: This mutates a variable after it was passed to React, which means that React cannot observe changes to it (4:4)
```
@@ -0,0 +1,6 @@
let wat = {};
function Foo() {
delete wat.foo;
return wat;
}
@@ -0,0 +1,21 @@
## Input
```javascript
let wat = {};
function Foo() {
wat.test = 1;
return wat;
}
```
## Error
```
[ReactForget] InvalidReact: This mutates a variable after it was passed to React, which means that React cannot observe changes to it (4:4)
```
@@ -0,0 +1,6 @@
let wat = {};
function Foo() {
wat.test = 1;
return wat;
}