fix: improve test regex to validate disallowed methods that can be bypassed by prototype reassignments and/or otherwise (#38214)
* fix: improve test regex to validate disallowed methods that can be bypassed by prototype reassignments and/or otherwise * fix: fixing regex pattern
This commit is contained in:
@ -33,7 +33,7 @@ tests:
|
||||
- text: Your code should use the <code>concat</code> method.
|
||||
testString: assert(code.match(/\.concat/g));
|
||||
- text: Your code should not use the <code>push</code> method.
|
||||
testString: assert(!code.match(/\.push/g));
|
||||
testString: assert(!code.match(/\.?[\s\S]*?push/g));
|
||||
- text: The <code>first</code> array should not change.
|
||||
testString: assert(JSON.stringify(first) === JSON.stringify([1, 2, 3]));
|
||||
- text: The <code>second</code> array should not change.
|
||||
|
@ -29,7 +29,7 @@ tests:
|
||||
- text: The <code>globalTitle</code> variable should not change.
|
||||
testString: assert(globalTitle === "Winter Is Coming");
|
||||
- text: Your code should not use the <code>replace</code> method for this challenge.
|
||||
testString: assert(!code.match(/\.replace/g));
|
||||
testString: assert(!code.match(/\.?[\s\S]*?replace/g));
|
||||
- text: <code>urlSlug("Winter Is Coming")</code> should return <code>"winter-is-coming"</code>.
|
||||
testString: assert(urlSlug("Winter Is Coming") === "winter-is-coming");
|
||||
- text: <code>urlSlug(" Winter Is Coming")</code> should return <code>"winter-is-coming"</code>.
|
||||
|
@ -31,7 +31,7 @@ tests:
|
||||
- text: Your code should use the <code>join</code> method.
|
||||
testString: assert(code.match(/\.join/g));
|
||||
- text: Your code should not use the <code>replace</code> method.
|
||||
testString: assert(!code.match(/\.replace/g));
|
||||
testString: assert(!code.match(/\.?[\s\S]*?replace/g));
|
||||
- text: <code>sentensify("May-the-force-be-with-you")</code> should return a string.
|
||||
testString: assert(typeof sentensify("May-the-force-be-with-you") === "string");
|
||||
- text: <code>sentensify("May-the-force-be-with-you")</code> should return <code>"May the force be with you"</code>.
|
||||
|
@ -26,7 +26,7 @@ tests:
|
||||
- text: <code>new_s</code> should equal <code>[46, 130, 196, 10]</code>.
|
||||
testString: assert(JSON.stringify(new_s) === JSON.stringify([46, 130, 196, 10]));
|
||||
- text: Your code should not use the <code>map</code> method.
|
||||
testString: assert(!code.match(/\.map/g));
|
||||
testString: assert(!code.match(/\.?[\s\S]*?map/g));
|
||||
|
||||
```
|
||||
|
||||
|
@ -24,7 +24,7 @@ tests:
|
||||
- text: <code>new_s</code> should equal <code>[23, 65, 5]</code>.
|
||||
testString: assert(JSON.stringify(new_s) === JSON.stringify([23, 65, 5]));
|
||||
- text: Your code should not use the <code>filter</code> method.
|
||||
testString: assert(!code.match(/\.filter/g));
|
||||
testString: assert(!code.match(/\.?[\s\S]*?filter/g));
|
||||
|
||||
```
|
||||
|
||||
|
@ -32,7 +32,7 @@ tests:
|
||||
- text: Your code should use the <code>slice</code> method.
|
||||
testString: assert(code.match(/\.slice/g));
|
||||
- text: Your code should not use the <code>splice</code> method.
|
||||
testString: assert(!code.match(/\.splice/g));
|
||||
testString: assert(!code.match(/\.?[\s\S]*?splice/g));
|
||||
- text: The <code>inputCities</code> array should not change.
|
||||
testString: assert(JSON.stringify(inputCities) === JSON.stringify(["Chicago", "Delhi", "Islamabad", "London", "Berlin"]));
|
||||
- text: <code>nonMutatingSplice(["Chicago", "Delhi", "Islamabad", "London", "Berlin"])</code> should return <code>["Chicago", "Delhi", "Islamabad"]</code>.
|
||||
|
Reference in New Issue
Block a user