From 82bfc07ae6085c4bc14f5f1e88ca6cb399d99c0f Mon Sep 17 00:00:00 2001 From: Till Breuer Date: Wed, 7 May 2014 14:00:11 +0200 Subject: [PATCH] Add pending context menu directive test --- ...ork-package-context-menu-directive-test.js | 44 ++++++++++++------- .../work_package_context_menu.html | 3 +- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/karma/tests/directives/work_packages/work-package-context-menu-directive-test.js b/karma/tests/directives/work_packages/work-package-context-menu-directive-test.js index 9351ad5186..91fe585c97 100644 --- a/karma/tests/directives/work_packages/work-package-context-menu-directive-test.js +++ b/karma/tests/directives/work_packages/work-package-context-menu-directive-test.js @@ -61,34 +61,48 @@ describe('workPackageContextMenu Directive', function() { }); describe('when the context menu context contains one work package', function() { - var actions = ['edit', 'move']; - var actionLinks = { - edit: '/work_packages/123/edit', - move: '/work_packages/move/new?ids%5B%5D=123', - }; - var workPackage = Factory.build('PlanningElement', { - _actions: actions, - _links: actionLinks - }); - - var directListElements, listElement; + var I18n; + var actions = ['edit', 'move'], + actionLinks = { + edit: '/work_packages/123/edit', + move: '/work_packages/move/new?ids%5B%5D=123', + }, + workPackage = Factory.build('PlanningElement', { + _actions: actions, + _links: actionLinks + }); + var directListElements; beforeEach(function() { ContextMenuService.setContext({rows: [], row: {object: workPackage}}); compile(); directListElements = element.find('.menu > li:not(.folder)'); - listElement = directListElements[0]; }); + beforeEach(inject(function(_I18n_) { + I18n = _I18n_; + sinon.stub(I18n, 't').withArgs('js.button_' + actions[0]).returns('anything'); + })); + afterEach(inject(function() { + I18n.t.restore(); + })); + it('lists link tags for any permitted action', function(){ expect(directListElements.length).to.equal(2); }); - it('lists link tags for any permitted action', function(){ - expect(listElement.className).to.equal('edit'); + it('assigns a css class named by the action', function(){ + expect(directListElements[0].className).to.equal(actions[0]); + }); + + it('adds an icon from the icon fonts to each list element', function() { + expect(element.find('.' + actions[0] +' a').attr('class')).to.include('icon-' + actions[0]); }); - // TODO continue + xit('translates the action name', function() { + expect(element.find('.' + actions[0] +' a').contents()).to.equal('anything'); + // TODO find out how to stub I18n.t inside directive + }); }); }); diff --git a/public/templates/work_packages/work_package_context_menu.html b/public/templates/work_packages/work_package_context_menu.html index e17f067720..c4e2ed1979 100644 --- a/public/templates/work_packages/work_package_context_menu.html +++ b/public/templates/work_packages/work_package_context_menu.html @@ -1,10 +1,9 @@
- {{permittedActions}}