fix(curriculum): update Redux store listener to not allow direct calls (#56625)

Co-authored-by: Lasse Jørgensen <28780271+lasjorg@users.noreply.github.com>
This commit is contained in:
Anna
2024-10-28 16:44:16 -04:00
committed by GitHub
parent e9a4e92955
commit e06f8a72ab

View File

@@ -32,19 +32,25 @@ assert(
There should be a listener function subscribed to the store using `store.subscribe`.
```js
(getUserInput) => assert(getUserInput('index').match(/store\s*\.\s*subscribe\(/gm));
assert.match(code, /store\s*\.\s*subscribe\(/gm);
```
The `store.subscribe` should receive a function.
```js
(getUserInput) => assert(getUserInput('index').match(/(\s*function\s*)|(\s*\(\s*\)\s*=>)/gm))
assert.match(code, /(\s*function\s*)|(\s*\(\s*\)\s*=>)/gm);
```
The function passed to `store.subscribe` should not be called.
```js
assert.notMatch(code, /store\.subscribe\(.+\(\)\)/);
```
The callback to `store.subscribe` should also increment the global `count` variable as the store is updated.
```js
assert(store.getState() === count);
assert.strictEqual(store.getState(), count);
```
# --seed--