Checking two boundaries with Jasmine (between matcher)

前端 未结 1 1864
醉酒成梦
醉酒成梦 2020-12-30 07:51

In Jasmine, there are toBeGreaterThan and toBeLessThan matchers.

What if I want to check an integer value in a specific range? Is there any

相关标签:
1条回答
  • 2020-12-30 08:36

    You can run the boolean comparison and assert the result is true:

    expect(x > 1 && x < 10).toBeTruthy();
    

    Also, there is toBeWithinRange() custom matcher introduced by jasmine-matchers:

    expect(x).toBeWithinRange(2, 9);  // range borders are included 
    
    0 讨论(0)
提交回复
热议问题