Wyświetlenie Chai expect/should documentation, jest kilka sposobów na wykonanie tego testu.
Pamiętaj, że możesz łączyć łańcuch za pomocą "i" ale najwyraźniej nie "lub" - żałuj, że nie mają tej funkcji.
- Sprawdź, czy przedmiot przechodzi test prawdzie
.satisfy (metoda)
@param{ Function }matcher
@param{ String }message_optional_
Asserts that the target passes a given truth test.
przykład:
expect(1).to.satisfy(function(num) { return num > 0; });
W przypadku, do testowania warunek "lub":
yourVariable.should.satisfy(function (num) {
if ((num === 4) || (num === 5)) {
return true;
} else {
return false;
}
});
- Sprawdź, czy liczba mieści się w przedziale:
W obrębie (początek, mety)
@param{ Number }startlowerbound inclusive
@param{ Number }finishupperbound inclusive
@param{ String }message_optional_
Asserts that the target is within a range.
przykład:
expect(7).to.be.within(5,10);
który działałby - moglibyśmy również zrobić coś takiego jak '(num == = 4 || num === 5) .should.be.true – MonkeyBonkey