2018-08-22 10:41:00 +00:00
|
|
|
describe('Directive bind', () => {
|
|
|
|
let compile;
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
beforeEach(ngModule('vnCore'));
|
2018-08-22 10:41:00 +00:00
|
|
|
|
2018-10-22 12:36:32 +00:00
|
|
|
compile = html => {
|
|
|
|
inject(($compile, $rootScope) => {
|
|
|
|
let $element = $compile(html)($rootScope);
|
|
|
|
$rootScope.$digest();
|
|
|
|
$element.remove();
|
2018-08-22 10:41:00 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
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`));
|
|
|
|
});
|
|
|
|
});
|