vendredi 30 octobre 2015

How to do unit test on the generated directive with different value in attr?

I have angular directive "Directive" with isolated scope and it's template and Unit test.

I insert 3 directive on the html page with different scope values.

I want to check out that each directives has own value which I have entered in the attributes and that there are 3 elements with Unit test.

class Directive {
 constructor () {
 'ngInject';

 let directive = {
 restrict: 'E',
 templateUrl: 'Directive.html',
 controller: Controller,
 controllerAs: 'vm',
 bindToController: true,
 scope: {
 buttonName: '@',
 classes: '@css'
 }
 };

 return directive;
 }
}
<label class="{{vm.classes}}" ng-model="radioModel" uib-btn-radio="{{vm.buttonName}}">{{vm.buttonName}}</label>

<div class="btn-group">
 <directive button-name="First" css="btn btn-primary classButton"></directive >
 <directive  button-name="Second" css="btn btn-primary classButton"></directive >
 <directive  button-name="Third" css="btn btn-primary classButton"></directive >
 </div>

Aucun commentaire:

Enregistrer un commentaire