Created
April 24, 2017 10:42
-
-
Save hawx/fca41eb23e573f4ff2252e9c9b5aca89 to your computer and use it in GitHub Desktop.
Testing radio buttons in Angular...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it('test', () => { | |
const element = ` | |
<section> | |
<label> | |
<input type="radio" | |
ng-value="true" | |
name="test" | |
ng-model="$ctrl.value" | |
hidden | |
required /> | |
Yes | |
</label> | |
<label> | |
<input type="radio" | |
ng-value="false" | |
name="test" | |
ng-model="$ctrl.value" | |
hidden | |
required /> | |
No | |
</label> | |
<div ng-if="$ctrl.value">what</div> | |
</section> | |
`; | |
let compiled = $compile(element)($scope); | |
$scope.$digest(); | |
compiled.find('label:first-child input').click().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