Access the controller on a directive as vm
in a Karma test. Also interact with the DOM.
describe('test withOUT max length', () => {
let $scope;
let element;
let vm;
beforeEach(() => {
$scope = $rootScope.$new();
$scope.numbers = '';
element = angular.element(
'<bc-keypad bc-number-model="numbers"></bc-keypad>'
);
element = $compile(element)($scope);
$scope.$apply();
vm = element.isolateScope().vm;
});
it('should add to the number model when small', () => {
const today = element[0].querySelectorAll('.bc-calendar__day--today')[0];
angular.element(today).triggerHandler('click');
expect(item).toEqual(value);
});
it('should add to the number model when large', () => {
expect(item).toEqual(value);
});
});