【问题标题】:How to use OR condition with should() in mocha如何在 mocha 中将 OR 条件与 should() 一起使用
【发布时间】:2017-01-19 16:31:55
【问题描述】:

我想使用两个值进行比较,以便如果其中一个为真,那么我的测试应该通过。使用下面的代码仅对第一个条件进行映射,并且测试失败。

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

}

我应该怎么做?

【问题讨论】:

    标签: javascript mocha.js should.js


    【解决方案1】:

    试试这个:

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

    documentation

    【讨论】:

      猜你喜欢
      • 2013-12-12
      • 2014-08-21
      • 1970-01-01
      • 2017-11-30
      • 2014-10-27
      • 1970-01-01
      • 2015-11-03
      • 1970-01-01
      • 2018-07-08
      相关资源
      最近更新 更多