multiple matchers

21 views
Skip to first unread message

Dorota Rupniewska

unread,
Jan 30, 2014, 4:53:39 AM1/30/14
to ang...@googlegroups.com
Is there any possibility to have more than one matcher in the same 'expect'? I need to check if given value is equal or grater than 0 so it could be something like: expect(value).toEqual(0).or.toBeGreaterThan(0)

Jeff Hubbard

unread,
Jan 30, 2014, 8:59:51 PM1/30/14
to ang...@googlegroups.com
While I agree with the general concept (multiple matchers), that example is a little too thin--you could solve that by doing `expect(value).toBeGreaterThan(-1);`. It's not as clear what the intent is, but it is correct.

Dorota Rupniewska

unread,
Feb 4, 2014, 7:57:27 AM2/4/14
to ang...@googlegroups.com
In this simple case I've mentioned, you are right - it could be 'expect(value).toBeGreaterThan(-1)'; but what I was looking for is simply defining custom matchers. I'm new to testing and didn't know I can define my own matcher


2014-01-31 Jeff Hubbard <lord...@gmail.com>:
While I agree with the general concept (multiple matchers), that example is a little too thin--you could solve that by doing `expect(value).toBeGreaterThan(-1);`. It's not as clear what the intent is, but it is correct.


On Thursday, January 30, 2014 1:53:39 AM UTC-8, Dorota Rupniewska wrote:
Is there any possibility to have more than one matcher in the same 'expect'? I need to check if given value is equal or grater than 0 so it could be something like: expect(value).toEqual(0).or.toBeGreaterThan(0)

--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/bLblw9FDzKA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages