Tarea #494 /directives/bind.js Front unit test

This commit is contained in:
gerard 2018-08-22 12:41:00 +02:00
parent e38e45c3fe
commit 05ea1dcbf1
1 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,35 @@
describe('Directive bind', () => {
let $scope;
let element;
let compile;
beforeEach(() => {
angular.mock.module('client');
});
compile = _element => {
inject(($compile, $rootScope, _$timeout_, _$httpBackend_) => {
$scope = $rootScope.$new();
element = angular.element(_element);
_$httpBackend_.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
$compile(element)($scope);
$scope.$digest();
});
};
it('should throw an error when the directive atribute is not set', () => {
let html = `<div id="test" vn-bind=""></div>`;
expect(() => {
compile(html);
}).toThrow(Error(`vnBind: Binding keys not defined`));
});
it('should throw an error when the command modifier is not valid', () => {
let html = `<div id="test" vn-bind="manzana +"></div>`;
expect(() => {
compile(html);
}).toThrow(new Error(`vnBind: Invalid modifier key in binding`));
});
});