Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use OR condition with should() in mocha

I want to use two values to get compared so that if either is true then my test should pass.Using the below code is comapring only 1st condition and failing the test.

if (typeof lng !== 'undefined') {
data.lng.should.equal(lng) || data.cityLng.should.equal(lng);

}

How should I do this?

like image 373
Shashi Kumar Raja Avatar asked Jan 19 '17 08:01

Shashi Kumar Raja


1 Answers

Try this:

if (typeof lng !== 'undefined') {
    lng.should.be.equalOneOf(data.lng, data.cityLng);

See documentation.

like image 88
Santanu Biswas Avatar answered Nov 15 '22 00:11

Santanu Biswas