mathiasbynens / mathiasbynens/String.prototype.includes
Add more test cases in Array, Object
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 70
- Forks
- 10
- PR merge metrics
- No merged PRs in 30d
Description
I understand that searchString is not accepted in RegExp. (TypeError exception)
Throwing an exception if the first argument is a RegExp is specified in order to allow future editions to define extensions that allow such argument values.
But it does accept Array and Object through the method toString under the specification.
which are
// array
['this', 'is', 'an', 'array'].toString(); // => 'this,is,an,array'
// object
({'obj': 'obj'}).toString(); // => '[object Object]'
Therefore, I would like to add more test cases
// array
assertEquals('this,is,an,array').includes(['this', 'is']), true);
assertEquals('this,is,an,array').includes(['this', 'is'], 1), false);
assertEquals('this, is, an, array').includes(['this', 'is']), false);
// object
assertEquals(String.prototype.includes.apply({ 'toString': function () { return '[object Object]'; }}, [{'obj': 'obj'}, 0]), true);
It’s weird if someone input the array or object to the method includes, but it does support.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No test file is named in the issue. Locate the existing tests for String.prototype.includes and compare their assertion style with the proposed Array and Object cases. Run that suite first, then add coverage for the shown conversions and verify the cases pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- testing-qa
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100