Skip to content

Commit 9d2f6dc

Browse files
Víctor Olivavoliva
Víctor Oliva
authored andcommitted
docs(oneOf): Add contains flag to oneOf documentation
1 parent 7eaf684 commit 9d2f6dc

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/chai/core/assertions.js

+8
Original file line numberDiff line numberDiff line change
@@ -3117,6 +3117,14 @@ module.exports = function (chai, _) {
31173117
* expect(1).to.equal(1); // Recommended
31183118
* expect(1).to.not.be.oneOf([2, 3, 4]); // Not recommended
31193119
*
3120+
* It can also be chained with `.contain` or `.include`, which will work with
3121+
* both arrays and strings:
3122+
*
3123+
* expect('Today is sunny').to.contain.oneOf(['sunny', 'cloudy'])
3124+
* expect('Today is rainy').to.not.contain.oneOf(['sunny', 'cloudy'])
3125+
* expect([1,2,3]).to.contain.oneOf([3,4,5])
3126+
* expect([1,2,3]).to.not.contain.oneOf([4,5,6])
3127+
*
31203128
* `.oneOf` accepts an optional `msg` argument which is a custom error message
31213129
* to show when the assertion fails. The message can also be given as the
31223130
* second argument to `expect`.

0 commit comments

Comments
 (0)