Add specs for custom properties on overview tab

pull/1598/head
Till Breuer 10 years ago
parent 1d2873f0f7
commit bee95eeab8
  1. 52
      karma/tests/controllers/work-package-details-controller-test.js

@ -35,10 +35,16 @@ describe('WorkPackageDetailsController', function() {
WorkPackagesHelper = { WorkPackagesHelper = {
formatWorkPackageProperty: angular.identity formatWorkPackageProperty: angular.identity
}, },
UserService = {
getUser: angular.identity
},
workPackage = { workPackage = {
props: { props: {
status: 'open', status: 'open',
versionName: null versionName: null,
customProperties: [
{ format: 'text', name: 'color', value: 'red' },
]
}, },
embedded: { embedded: {
activities: [] activities: []
@ -67,6 +73,7 @@ describe('WorkPackageDetailsController', function() {
return false; return false;
} }
}, },
UserService: UserService,
workPackage: buildWorkPackageWithId(workPackageId), workPackage: buildWorkPackageWithId(workPackageId),
}); });
@ -232,6 +239,49 @@ describe('WorkPackageDetailsController', function() {
}); });
}); });
}); });
describe('custom field properties', function() {
var customPropertyName = 'color';
describe('when the property has a value', function() {
beforeEach(function() {
buildController();
});
it('adds properties to present properties', function() {
expect(fetchPresentPropertiesWithName(customPropertyName)).to.have.length(1);
});
});
describe('when the property does not have a value', function() {
beforeEach(function() {
workPackage.props.customProperties[0].value = null;
buildController();
});
it('adds the custom property to empty properties', function() {
expect(scope.emptyWorkPackageProperties.indexOf(customPropertyName)).to.be.greaterThan(-1);
});
});
describe('user custom property', function() {
var userId = '1';
beforeEach(function() {
workPackage.props.customProperties[0].value = userId;
workPackage.props.customProperties[0].format = 'user';
getUserSpy = sinon.spy(UserService, 'getUser');
buildController();
});
it('fetches the user using the user service', function() {
expect(UserService.getUser.calledWith(userId)).to.be.true;
});
});
});
}); });
}); });

Loading…
Cancel
Save