mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-03-12 07:02:42 -04:00
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:
@@ -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--
|
||||
|
||||
Reference in New Issue
Block a user