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.
// ++
describe('toolbar Directive', function() {
var expect = chai.expect;
describe('toolbar Directive', () => {
var compile, element, rootScope, scope;
beforeEach(angular.mock.module('openproject.uiComponents'));
beforeEach(angular.mock.module('openproject.templates'));
beforeEach(angular.mock.inject(function($rootScope, $compile) {
beforeEach(angular.mock.inject(($rootScope, $compile) => {
var html;
html = '<div wp-toolbar></div>';
@ -41,22 +43,20 @@ describe('toolbar Directive', function() {
scope = $rootScope.$new();
scope.doNotShow = true;
compile = function() {
compile = () => {
$compile(element)(scope);
scope.$digest();
};
}));
describe('element', function() {
beforeEach(function() {
compile();
});
describe('element', () => {
beforeEach(() => compile());
it('should preserve its div', function() {
it('should preserve its 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;
});
});

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