我有一个方法:
const validate = ({ foo, bar }) => foo && bar
从本质上讲,只要您传递带有foo
和bar
键集的对象,该方法就会返回true
尝试对此进行存根,并努力查看如何做到这一点:
validate: stub().withArgs(???).returns(true)
我想将不同的数据(不同的断言)传递到validate
存根中,并且只有在传入的对象中同时设置了foo
和bar
键的情况下,才使它返回true。
例如:
t.is(validate({ foo: 'foo', bar: 'bar' }), true)
t.is(validate({ foo: 'foo' }), false)