I have the following set up in my unit-test:
'use strict';
describe('Unit Testing the select-backdrop directive', function() {
var $scope, $compile, $ionicBackdrop;
beforeEach(module(function($provide) {
$provide.value($ionicBackdrop, {});
}));
beforeEach(inject(function(_$rootScope_, _$compile_, _$ionicBackdrop_) {
$scope = _$rootScope_.$new();
$compile = _$compile_;
$ionicBackdrop = _$ionicBackdrop_;
$scope.items = ['Pizza', 'Gyro', 'Burger'];
$scope.model = $scope.items[0];
}));
it('Should attach a "focus" and "blur" event to a <select> element', function() {
var element = $compile('<select ng-model="model" ng-options="item for item in items" select-backdrop></select>')($scope);
$scope.$digest();
console.log(element.html());
expect(element.find('option').length).toBe(3);
});
});
I'm trying to test the select-backdrop directive. However, $compile is returning a list of option instead of the select element. Is there something I'm forgetting to do?
Aucun commentaire:
Enregistrer un commentaire