salix/front/core/directives/specs/id.spec.js

38 lines
1.0 KiB
JavaScript
Raw Normal View History

2017-10-24 05:57:25 +00:00
describe('Directive vnId', () => {
let $scope;
let $element;
let compile;
2019-09-13 14:09:14 +00:00
beforeEach(angular.mock.module('vnCore', $translateProvider => {
$translateProvider.translations('en', {});
}));
2017-10-24 05:57:25 +00:00
compile = _element => {
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>`;
expect(() => {
2017-10-24 05:57:25 +00:00
compile(html);
}).toThrow(new Error(`vnId: Attribute can't be null`));
});
// FIXME: Sometimes fails with '$scope is undefined'
xit(`should set the controller into the $scope as there are no errors being thrown`, () => {
let html = `<form vn-id="1"></form>`;
expect($scope['1']).not.toBeDefined();
compile(html);
expect($scope['1']).toBeDefined();
});
2017-10-24 05:57:25 +00:00
});