0

これが私の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 テストlengthで ofを設定するにはどうすればよいですか?$("#payment_cc:checked")

4

1 に答える 1

0

lengthjQuery 要素の選択を設定する代わりに、次のようにラジオ ボタンを手動でチェックするように設定します。

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
    });
});
于 2014-09-19T13:20:49.290 に答える