Chai expect/should documentation देखकर, इस परीक्षण को करने के कई तरीके हैं।
ध्यान दें कि आप "और" का उपयोग करके श्रृंखला बना सकते हैं लेकिन स्पष्ट रूप से नहीं "या" - इच्छा है कि उनके पास यह कार्यक्षमता हो।
- चेक एक वस्तु एक सच परीक्षण में सफ़ल या नहीं:
.satisfy (विधि)
@param{ Function }matcher
@param{ String }message_optional_
Asserts that the target passes a given truth test.
उदाहरण:
expect(1).to.satisfy(function(num) { return num > 0; });
आपके मामले में, परीक्षण करने के लिए एक "या" हालत:
yourVariable.should.satisfy(function (num) {
if ((num === 4) || (num === 5)) {
return true;
} else {
return false;
}
});
- चेक कि क्या एक नंबर एक सीमा के भीतर है:
.within (शुरू, खत्म)
@param{ Number }startlowerbound inclusive
@param{ Number }finishupperbound inclusive
@param{ String }message_optional_
Asserts that the target is within a range.
उदाहरण:
expect(7).to.be.within(5,10);
जो काम करेगा - हम कुछ भी कर सकते हैं जैसे '(num == = 4 || संख्या === 5) .should.be.true – MonkeyBonkey