samedi 2 mai 2015

Unit test a directive with templateUrl with attributes

I need to test a directive. I gotten everything to work with ngHtml2JsPreprocessor etc.

But how do I mock an attribute in a test?

I tried this:

beforeEach(inject(function ($rootScope, $compile) {
        scope = $rootScope.$new();
        var mockFlow = 500;

        element = $compile('<flow-power flow=' + mockFlow  +'></flow-power>')(scope);
        $rootScope.$digest();
      }));

it('should have an attribute flow', function(){
  expect(scope.flow).toEqual(500); //undefined
})

Aucun commentaire:

Enregistrer un commentaire