Add pending context menu directive test

pull/1263/head
Till Breuer 11 years ago
parent 9d755323de
commit 82bfc07ae6
  1. 44
      karma/tests/directives/work_packages/work-package-context-menu-directive-test.js
  2. 3
      public/templates/work_packages/work_package_context_menu.html

@ -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
});
});
});

@ -1,10 +1,9 @@
<div id="context-menu" ng-show="opened">
{{permittedActions}}
<ul class="menu">
<li ng-repeat="(action, link) in permittedActions"
class="{{action}}">
<a ng-href="{{link}}"
ng-class="['icon-context', 'icon-' + action.gsub('_', '-')]"
ng-class="['icon-context', 'icon-' + action]"
ng-bind="I18n.t('js.button_' + action)">
</a>
</li>

Loading…
Cancel
Save