Refactor the WP toolbar directive using TypeScript

pull/4010/head
Alex Dik 9 years ago
parent 7767feb66e
commit e2ebc59584
  1. 18
      frontend/app/components/work-packages/directives/wp-toolbar/wp-toolbar.directive.test.ts
  2. 5
      frontend/app/components/work-packages/directives/wp-toolbar/wp-toolbar.directive.ts

@ -26,13 +26,15 @@
// See doc/COPYRIGHT.rdoc for more details. // See doc/COPYRIGHT.rdoc for more details.
// ++ // ++
describe('toolbar Directive', function() { var expect = chai.expect;
describe('toolbar Directive', () => {
var compile, element, rootScope, scope; var compile, element, rootScope, scope;
beforeEach(angular.mock.module('openproject.uiComponents')); beforeEach(angular.mock.module('openproject.uiComponents'));
beforeEach(angular.mock.module('openproject.templates')); beforeEach(angular.mock.module('openproject.templates'));
beforeEach(angular.mock.inject(function($rootScope, $compile) { beforeEach(angular.mock.inject(($rootScope, $compile) => {
var html; var html;
html = '<div wp-toolbar></div>'; html = '<div wp-toolbar></div>';
@ -41,22 +43,20 @@ describe('toolbar Directive', function() {
scope = $rootScope.$new(); scope = $rootScope.$new();
scope.doNotShow = true; scope.doNotShow = true;
compile = function() { compile = () => {
$compile(element)(scope); $compile(element)(scope);
scope.$digest(); scope.$digest();
}; };
})); }));
describe('element', function() { describe('element', () => {
beforeEach(function() { beforeEach(() => compile());
compile();
});
it('should preserve its div', function() { it('should preserve its div', () => {
expect(element.prop('tagName')).to.equal('DIV'); expect(element.prop('tagName')).to.equal('DIV');
}); });
it('should be in a collapsed state', function() { it('should be in a collapsed state', () => {
expect(element.is(":visible")).to.be.false; expect(element.is(":visible")).to.be.false;
}); });
}); });

@ -30,11 +30,12 @@ angular
.module('openproject.uiComponents') .module('openproject.uiComponents')
.directive('wpToolbar', wpToolbar); .directive('wpToolbar', wpToolbar);
function wpToolbar() { function wpToolbar(): ng.IDirective {
return { return {
restrict: 'A', restrict: 'A',
link: function(scope, element, attributes) { link: function(scope: ng.IScope, element: ng.IAugmentedJQuery) {
} }
}; };
} }
Loading…
Cancel
Save