Tarea #494 /directives/bind.js Front unit test
This commit is contained in:
parent
e38e45c3fe
commit
05ea1dcbf1
|
@ -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`));
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue