lient side unit test for id directive

This commit is contained in:
Carlos 2017-10-24 07:57:25 +02:00
parent c88023182a
commit f6c1f5f137
1 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,34 @@
describe('Directive vnId', () => {
let $scope;
let $element;
let compile;
beforeEach(() => {
angular.mock.module('client');
});
compile = _element => {
inject(($compile, $rootScope) => {
$scope = $rootScope.$new();
$element = angular.element(_element);
$compile($element)($scope);
$scope.$digest();
});
};
it(`should throw an error when there's no id defined`, () => {
let html = `<form vn-id=""></form>`;
expect(function errorExpected() {
compile(html);
}).toThrow(new Error(`vnId: Attribute can't be null`));
});
it(`should throw an error when these's no controller defined in $element[0]`, () => {
let html = `<div vn-id="1"></div>`;
expect(function errorExpected() {
compile(html);
}).toThrow(new Error(`vnId: Can't find controller for element '1'`));
});
});