mathiasbynens / mathiasbynens/String.prototype.includes
Add more test cases in Array, Object
- 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](https://tc39.github.io/ecma262/#sec-string.prototype.includes).
which are
``` js
// 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
``` js
// 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
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