2018-12-20 13:37:29 +00:00
|
|
|
|
2017-10-24 05:57:25 +00:00
|
|
|
describe('Directive vnId', () => {
|
|
|
|
let $scope;
|
|
|
|
let $element;
|
|
|
|
let compile;
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
beforeEach(ngModule('vnCore'));
|
2017-10-24 05:57:25 +00:00
|
|
|
|
|
|
|
compile = _element => {
|
2018-12-20 13:37:29 +00:00
|
|
|
inject(($compile, $rootScope) => {
|
2017-10-24 05:57:25 +00:00
|
|
|
$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>`;
|
|
|
|
|
2017-10-24 06:08:58 +00:00
|
|
|
expect(() => {
|
2017-10-24 05:57:25 +00:00
|
|
|
compile(html);
|
|
|
|
}).toThrow(new Error(`vnId: Attribute can't be null`));
|
|
|
|
});
|
|
|
|
|
2020-01-24 11:38:08 +00:00
|
|
|
it(`should set the controller into the $scope as there are no errors being thrown`, () => {
|
|
|
|
let html = `<form vn-id="myId"></form>`;
|
2017-10-24 06:08:58 +00:00
|
|
|
compile(html);
|
|
|
|
|
2020-01-24 11:38:08 +00:00
|
|
|
expect($scope.myId).toBeDefined();
|
2017-10-24 06:08:58 +00:00
|
|
|
});
|
2017-10-24 05:57:25 +00:00
|
|
|
});
|