給出:
<div>
<div class="input-group" ng-repeat="item in vm.dataFiles | filter:vm.query">
<span class="input-group-addon">
<input type="checkbox" ng-model="item.isChecked">
</span>
<label class="form-control">{{item.name}}</label>
</div>
</div>
這是我的E2E的測試,可以幫助你在某種程度上部分。 請注意,我的複選框綁定到「item.isChecked」
it("should disable the create button when there are no checked items in the vm.dataFiles", function() {
var dataFiles = element.all(by.repeater("item in vm.dataFiles"));
var firstCheckbox = dataFiles.get(0).element(by.model("item.isChecked"));
var btnCreate = element(by.id("btnCreate"));
expect(btnCreate.isEnabled()).not.toBeTruthy();
firstCheckbox.click();
expect(btnCreate.isEnabled()).toBeTruthy();
firstCheckbox.click();
expect(btnCreate.isEnabled()).not.toBeTruthy();
});