Skip to content

Instantly share code, notes, and snippets.

@hawx
Created April 24, 2017 10:47
Show Gist options
  • Save hawx/6a3b30a7394051969de12df48ca31dba to your computer and use it in GitHub Desktop.
Save hawx/6a3b30a7394051969de12df48ca31dba to your computer and use it in GitHub Desktop.
Testing checkbox in Angular...
it('test', () => {
const element = `
<section>
<label>
<input type="checkbox" name="test" ng-model="$ctrl.value" />
ok
</label>
<div ng-if="$ctrl.value">what</div>
</section>
`;
let compiled = $compile(element)($scope);
$scope.$digest();
compiled.find('input').trigger('click');
$scope.$digest();
assert.equal(compiled.find('div').text(), 'what');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment