Added some tests for options dropdown directive.

pull/1384/head
Richard 11 years ago
parent 009b5c95c2
commit d26aba9eaa
  1. 4
      app/assets/javascripts/angular/directives/work_packages/options-dropdown-directive.js
  2. 7
      karma.conf.js
  3. 104
      karma/tests/directives/work_packages/options-dropdown-directive-test.js

@ -63,8 +63,8 @@ angular.module('openproject.workPackages.directives')
}
};
scope.deleteQuery = function(){
if( deleteConfirmed() ){
scope.deleteQuery = function(event){
if( preventDisabledAction(event) && deleteConfirmed() ){
QueryService.deleteQuery()
.then(function(data){
settingsModal.deactivate();

@ -92,6 +92,13 @@ module.exports = function(config) {
"app/assets/javascripts/angular/controllers/timelines-controller.js",
"app/assets/javascripts/angular/controllers/work-packages-controller.js",
"app/assets/javascripts/angular/controllers/work-package-details-controller.js",
"app/assets/javascripts/angular/controllers/dialogs/columns.js",
"app/assets/javascripts/angular/controllers/dialogs/export.js",
"app/assets/javascripts/angular/controllers/dialogs/group-by.js",
"app/assets/javascripts/angular/controllers/dialogs/save.js",
"app/assets/javascripts/angular/controllers/dialogs/settings.js",
"app/assets/javascripts/angular/controllers/dialogs/share.js",
"app/assets/javascripts/angular/controllers/dialogs/sorting.js",
'app/assets/javascripts/date-en-US.js',

@ -0,0 +1,104 @@
//-- copyright
// OpenProject is a project management system.
// Copyright (C) 2012-2014 the OpenProject Foundation (OPF)
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License version 3.
//
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
// Copyright (C) 2006-2013 Jean-Philippe Lang
// Copyright (C) 2010-2013 the ChiliProject Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// See doc/COPYRIGHT.rdoc for more details.
//++
describe('optionsDropdown Directive', function() {
var compile, element, rootScope, scope;
beforeEach(angular.mock.module('openproject.workPackages.directives'));
beforeEach(module('templates', 'openproject.models', 'openproject.workPackages.controllers'));
beforeEach(inject(function($rootScope, $compile) {
var optionsDropdownHtml;
optionsDropdownHtml = '<div options-dropdown><a href ng-click="showSaveAsModal($event)" ng-class="{\'inactive\': query.isNew()}"></a></div>';
element = angular.element(optionsDropdownHtml);
rootScope = $rootScope;
scope = $rootScope.$new();
compile = function() {
$compile(element)(scope);
scope.$digest();
};
}));
describe('element', function() {
it('should render a div', function() {
expect(element.prop('tagName')).to.equal('DIV');
});
describe('inactive options', function(){
beforeEach(function(){
var query = new Query({
});
scope.query = query;
compile();
});
it('should have an inactive save as option', function() {
var saveAsLink = element.find('a').first();
expect(saveAsLink.hasClass('inactive')).to.be.ok;
});
it('should not open save as modal', function() {
var saveAsLink = element.find('a').first();
saveAsLink.click();
expect(jQuery('.ng-modal-window').length).to.equal(0);
});
});
describe('active options', function(){
beforeEach(function(){
var query = new Query({
id: 1
});
scope.query = query;
compile();
})
it('should have an active save as option', function() {
var saveAsLink = element.find('a').first();
expect(saveAsLink.hasClass('inactive')).to.not.be.ok;
});
it('should open save as modal', function() {
var saveAsLink = element.find('a').first();
saveAsLink.click();
expect(jQuery('.ng-modal-window').length).to.equal(1);
var modal = jQuery(jQuery('.ng-modal-window')[0]);
expect(modal.find('h3').text()).to.equal('Save as');
});
});
});
});
Loading…
Cancel
Save