fix(client): remove JS comments from user code for tests (#41873)

* Removes comments in js challanges by default

* fix local-scope-and-functions test regex

* fix all languages

* revert language changes

* removed unnecessary removeJSComments from challenges

* fix challanges in other languages

* removed removeJSComments from all challanges
This commit is contained in:
Evgeny Klimenchenko
2021-04-28 16:18:54 +01:00
committed by GitHub
parent ebe8f99345
commit db369fbed1
47 changed files with 103 additions and 149 deletions

View File

@ -32,11 +32,7 @@ Make the promise handle success and failure. If `responseFromServer` is `true`,
```js
assert(
__helpers
.removeJSComments(code)
.match(
/if\s*\(\s*responseFromServer\s*\)\s*{\s*resolve\s*\(\s*('|"|`)We got the data\1\s*\)(\s*|\s*;\s*)}/g
)
code.match(/if\s*\(\s*responseFromServer\s*\)\s*{\s*resolve\s*\(\s*('|"|`)We got the data\1\s*\)(\s*|\s*;\s*)}/g)
);
```
@ -44,11 +40,7 @@ assert(
```js
assert(
__helpers
.removeJSComments(code)
.match(
/}\s*else\s*{\s*reject\s*\(\s*('|"|`)Data not received\1\s*\)(\s*|\s*;\s*)}/g
)
code.match(/}\s*else\s*{\s*reject\s*\(\s*('|"|`)Data not received\1\s*\)(\s*|\s*;\s*)}/g)
);
```

View File

@ -43,9 +43,7 @@ You should remove the ES5 assignment syntax.
```js
assert(
!__helpers
.removeJSComments(code)
.match(/today\s*=\s*HIGH_TEMPERATURES\.(today|tomorrow)/g)
!code.match(/today\s*=\s*HIGH_TEMPERATURES\.(today|tomorrow)/g)
);
```
@ -53,11 +51,7 @@ You should use destructuring to create the `today` variable.
```js
assert(
__helpers
.removeJSComments(code)
.match(
/(var|let|const)\s*{\s*(today[^}]*|[^,]*,\s*today)\s*}\s*=\s*HIGH_TEMPERATURES(;|\s+|\/\/)/g
)
code.match(/(var|let|const)\s*{\s*(today[^}]*|[^,]*,\s*today)\s*}\s*=\s*HIGH_TEMPERATURES(;|\s+|\/\/)/g)
);
```
@ -65,11 +59,7 @@ You should use destructuring to create the `tomorrow` variable.
```js
assert(
__helpers
.removeJSComments(code)
.match(
/(var|let|const)\s*{\s*(tomorrow[^}]*|[^,]*,\s*tomorrow)\s*}\s*=\s*HIGH_TEMPERATURES(;|\s+|\/\/)/g
)
code.match(/(var|let|const)\s*{\s*(tomorrow[^}]*|[^,]*,\s*tomorrow)\s*}\s*=\s*HIGH_TEMPERATURES(;|\s+|\/\/)/g)
);
```

View File

@ -39,7 +39,7 @@ Refactor the function `setGear` inside the object `bicycle` to use the shorthand
Traditional function expression should not be used.
```js
(getUserInput) => assert(!__helpers.removeJSComments(code).match(/function/));
(getUserInput) => assert(!code.match(/function/));
```
`setGear` should be a declarative function.