dgl viru
dgl viru

Reputation: 177

Using OR operator in expect statement of Protractor

How to use OR operator in expect statement. Below is my code

var now= someTime;
var nowPlus = someTime;
expect(updatedRefreshedTime).toEqual(now || nowMinus);

I want something like this.

Upvotes: 1

Views: 879

Answers (2)

yong
yong

Reputation: 13722

1) If updatedRefreshedTime is a promise.

var now= someTime;
var nowPlus = someTime;
updatedRefreshedTime.then(function(data){
   expect(data === now || data === nowMinus).toBe(true);
});

2) Otherwise

expect(updatedRefreshedTime === now || updatedRefreshedTime === nowMinus).toBe(true);

Upvotes: 1

Kacper
Kacper

Reputation: 1199

I can see two possibilities:

  1. Without Chai:

You can create an array [now, nowMinus] and check is updatedRefreshedTime in an array.

  1. With Chai:

Use chai-quantifiers plugin. Second it in examples seems to be suitable for your issue.

Upvotes: 0

Related Questions