Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 我能用Jasmine更改复选框的状态吗?_Jquery_Karma Jasmine - Fatal编程技术网

Jquery 我能用Jasmine更改复选框的状态吗?

Jquery 我能用Jasmine更改复选框的状态吗?,jquery,karma-jasmine,Jquery,Karma Jasmine,我正在尝试编写一个测试,在选中复选框后检查一个值,但它始终返回一个失败的测试 我认为这就像使用jQuery将其值设置为checked一样简单,但它似乎不起作用 我的输入附带了一个更改事件: $("input#p1").change(function() { pprompts.settings.aiGoesFirst = $(this).is(":checked"); }); 我的测试: it('should allow the user to choose who goes first

我正在尝试编写一个测试,在选中复选框后检查一个值,但它始终返回一个失败的测试

我认为这就像使用jQuery将其值设置为checked一样简单,但它似乎不起作用

我的输入附带了一个更改事件:

$("input#p1").change(function()
{
    pprompts.settings.aiGoesFirst = $(this).is(":checked");
});
我的测试:

it('should allow the user to choose who goes first', function()
{
    // the user goes first by default - PASSES
    expect(pprompts.settings.aiGoesFirst).toBe(false);

    // trigger the checkbox for ai to go first and check if AI is going first - FAILS
    $("input#p1").attr("checked","checked");
    expect(pprompts.settings.aiGoesFirst).toBe(true);
});

任何指导都将不胜感激。

我认为选中的设置不会触发更改事件。例如,请看:谢谢你。我已经更新了脚本以更改属性,然后触发更改,但仍然失败。