kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
208 lines
5.6 KiB
208 lines
5.6 KiB
9 years ago
|
// -- copyright
|
||
11 years ago
|
// OpenProject is a project management system.
|
||
10 years ago
|
// Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
|
||
11 years ago
|
//
|
||
|
// 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.
|
||
9 years ago
|
// ++
|
||
10 years ago
|
|
||
9 years ago
|
describe('wpDisplayAttr directive', () => {
|
||
|
var compile;
|
||
|
var element;
|
||
|
var rootScope;
|
||
|
var scope;
|
||
9 years ago
|
|
||
|
beforeEach(angular.mock.module('openproject.workPackages.directives'));
|
||
|
beforeEach(angular.mock.module('openproject.templates',
|
||
9 years ago
|
'openproject.api',
|
||
|
'openproject.services'));
|
||
9 years ago
|
|
||
9 years ago
|
beforeEach(angular.mock.module('openproject.templates', $provide => {
|
||
|
$provide.constant('ConfigurationService', {
|
||
|
isTimezoneSet: sinon.stub().returns(false)
|
||
|
});
|
||
9 years ago
|
}));
|
||
|
|
||
9 years ago
|
beforeEach(angular.mock.inject(($rootScope, $compile) => {
|
||
|
var html = `
|
||
|
<wp-display-attr object="workPackage" schema="schema" attribute="attribute">
|
||
|
</wp-display-attr>
|
||
|
`;
|
||
9 years ago
|
|
||
|
element = angular.element(html);
|
||
|
rootScope = $rootScope;
|
||
|
scope = $rootScope.$new();
|
||
|
|
||
9 years ago
|
compile = () => {
|
||
9 years ago
|
$compile(element)(scope);
|
||
|
scope.$digest();
|
||
|
};
|
||
|
}));
|
||
|
|
||
9 years ago
|
var getInnermostSpan = start => start.find('span').last();
|
||
9 years ago
|
|
||
9 years ago
|
describe('element', () => {
|
||
|
beforeEach(inject(function ($q) {
|
||
9 years ago
|
scope.workPackage = {
|
||
|
subject: 'Subject1',
|
||
9 years ago
|
type: {id: 1, name: 'Bug'},
|
||
9 years ago
|
sheep: 10,
|
||
9 years ago
|
customField1: 'asdf1234',
|
||
|
};
|
||
9 years ago
|
scope.schema = {
|
||
|
"$load": () => $q.when(true),
|
||
9 years ago
|
"_type": "Schema",
|
||
|
"type": {
|
||
|
"type": "Type",
|
||
|
"name": "Type",
|
||
|
"required": true,
|
||
|
"writable": true,
|
||
|
"_links": {},
|
||
|
"_embedded": {}
|
||
|
},
|
||
|
"subject": {
|
||
|
"type": "String",
|
||
|
"name": "Subject",
|
||
|
"required": true,
|
||
|
"writable": true,
|
||
|
"minLength": 1,
|
||
|
"maxLength": 255
|
||
|
},
|
||
|
"sheep": {
|
||
|
"type": "Integer",
|
||
|
"name": "Sheep",
|
||
|
"required": true,
|
||
|
"writable": true
|
||
|
},
|
||
|
"sheep": {
|
||
|
"type": "Integer",
|
||
|
"name": "Sheep",
|
||
|
"required": true,
|
||
|
"writable": true
|
||
|
},
|
||
|
"customField1": {
|
||
9 years ago
|
"type": "String",
|
||
|
"name": "foobar",
|
||
|
"required": false,
|
||
|
"writable": true
|
||
9 years ago
|
}
|
||
9 years ago
|
};
|
||
9 years ago
|
}));
|
||
11 years ago
|
|
||
9 years ago
|
describe('rendering an object field', () => {
|
||
|
beforeEach(() => {
|
||
9 years ago
|
scope.attribute = 'type';
|
||
9 years ago
|
compile();
|
||
|
});
|
||
11 years ago
|
|
||
9 years ago
|
it('should contain the object title', () => {
|
||
9 years ago
|
var content = getInnermostSpan(element);
|
||
10 years ago
|
|
||
9 years ago
|
expect(content.text().trim()).to.equal('Bug');
|
||
9 years ago
|
});
|
||
9 years ago
|
|
||
9 years ago
|
it('should have the object title as title attribute', () => {
|
||
9 years ago
|
var tag = getInnermostSpan(element);
|
||
11 years ago
|
|
||
9 years ago
|
expect(tag.attr('title')).to.equal('Bug');
|
||
|
});
|
||
|
});
|
||
11 years ago
|
|
||
9 years ago
|
describe('rendering a text field', () => {
|
||
|
beforeEach(() => {
|
||
9 years ago
|
scope.attribute = 'subject';
|
||
9 years ago
|
compile();
|
||
11 years ago
|
});
|
||
|
|
||
9 years ago
|
it('should contain the text', () => {
|
||
9 years ago
|
var content = getInnermostSpan(element);
|
||
|
|
||
9 years ago
|
expect(content.text().trim()).to.equal('Subject1');
|
||
11 years ago
|
});
|
||
|
|
||
9 years ago
|
it('should contain the text as the title', () => {
|
||
9 years ago
|
var tag = getInnermostSpan(element);
|
||
|
|
||
|
expect(tag.attr('title')).to.equal('Subject1');
|
||
11 years ago
|
});
|
||
9 years ago
|
});
|
||
|
|
||
9 years ago
|
describe('rendering a number field', () => {
|
||
|
beforeEach(() => {
|
||
9 years ago
|
scope.attribute = 'sheep';
|
||
9 years ago
|
compile();
|
||
11 years ago
|
});
|
||
|
|
||
9 years ago
|
it('should contain the text', () => {
|
||
9 years ago
|
var content = getInnermostSpan(element);
|
||
|
|
||
9 years ago
|
expect(content.text().trim()).to.equal('10');
|
||
11 years ago
|
});
|
||
|
|
||
9 years ago
|
it('should contain the text as the title', () => {
|
||
9 years ago
|
var tag = getInnermostSpan(element);
|
||
|
|
||
|
expect(tag.attr('title')).to.equal('10');
|
||
11 years ago
|
});
|
||
9 years ago
|
});
|
||
|
|
||
9 years ago
|
describe('rendering a custom string field', () => {
|
||
|
beforeEach(() => {
|
||
9 years ago
|
scope.attribute = 'customField1';
|
||
9 years ago
|
compile();
|
||
11 years ago
|
});
|
||
|
|
||
9 years ago
|
it('should contain the text', () => {
|
||
9 years ago
|
var content = getInnermostSpan(element);
|
||
|
|
||
9 years ago
|
expect(content.text().trim()).to.equal('asdf1234');
|
||
9 years ago
|
});
|
||
|
|
||
9 years ago
|
it('should contain the text as the title', () => {
|
||
9 years ago
|
var tag = getInnermostSpan(element);
|
||
|
|
||
|
expect(tag.attr('title')).to.equal('asdf1234');
|
||
|
});
|
||
11 years ago
|
});
|
||
10 years ago
|
|
||
9 years ago
|
describe('rendering missing field', () => {
|
||
|
beforeEach(() => {
|
||
9 years ago
|
scope.attribute = 'non-existant-field';
|
||
9 years ago
|
compile();
|
||
|
});
|
||
|
|
||
9 years ago
|
it('should contain the display empty text', () => {
|
||
9 years ago
|
var content = getInnermostSpan(element);
|
||
|
|
||
9 years ago
|
expect(content.text().trim()).to.equal('');
|
||
9 years ago
|
});
|
||
|
|
||
9 years ago
|
it('should contain the empty text as the title', () => {
|
||
9 years ago
|
var tag = getInnermostSpan(element);
|
||
10 years ago
|
|
||
9 years ago
|
expect(tag.attr('title')).to.equal('');
|
||
10 years ago
|
});
|
||
10 years ago
|
});
|
||
9 years ago
|
});
|
||
11 years ago
|
});
|