diff --git a/client/core/src/directives/specs/id.spec.js b/client/core/src/directives/specs/id.spec.js new file mode 100644 index 0000000000..9fddae55f4 --- /dev/null +++ b/client/core/src/directives/specs/id.spec.js @@ -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 = `
`; + + 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 = ``; + + expect(function errorExpected() { + compile(html); + }).toThrow(new Error(`vnId: Can't find controller for element '1'`)); + }); +});