这是我的Javascript:
if $("#payment_cc:checked").length > 0
path = "/orders"
if @get('tokenize')
@_submitWithToken(obj, path)
else
@_submitWithCC(obj, path)
else
path = "/orders/paypal"
@_submitWithCC(obj, path)我正在尝试在我的Javascript规范中模拟,这样我就可以测试什么时候:
$("#payment_cc:checked").length == 1
$("#payment_cc:checked").length == 0如何在Konacha测试中设置$("#payment_cc:checked")的length?
发布于 2014-09-19 21:20:49
不需要设置jQuery元素选择的length,只需将单选按钮设置为手动选中,如下所示:
describe('when the radio is selected', function() {
beforeEach(function() {
$('#payment_cc').attr('checked', true);
});
it('should do something', function() {
// Assert that the submission went the way you wanted it to
});
});https://stackoverflow.com/questions/25917838
复制相似问题