Extend wpDisplayAttr test

pull/4444/head
Oliver Günther 9 years ago
parent 809aacdbff
commit 6e50a03877
  1. 18
      frontend/app/components/work-packages/wp-display-attr/wp-display-attr.directive.test.ts
  2. 3
      frontend/app/components/work-packages/wp-display-attr/wp-display-attr.directive.ts

@ -29,6 +29,7 @@
describe('wpDisplayAttr directive', () => {
var compile;
var element;
var wpEditForm;
var rootScope;
var scope;
var I18n;
@ -49,7 +50,7 @@ describe('wpDisplayAttr directive', () => {
beforeEach(angular.mock.inject(($rootScope, $compile, _I18n_) => {
var html = `
<wp-display-attr work-package="workPackage" schema="schema" attribute="attribute">
<wp-display-attr work-package="workPackage" attribute="attribute">
</wp-display-attr>
`;
@ -62,6 +63,12 @@ describe('wpDisplayAttr directive', () => {
rootScope = $rootScope;
scope = $rootScope.$new();
// Link to wpEditForm
wpEditForm = {
onWorkPackageUpdated: sinon.spy()
}
element.data("$wpEditFormController", wpEditForm);
compile = () => {
$compile(element)(scope);
scope.$digest();
@ -82,9 +89,8 @@ describe('wpDisplayAttr directive', () => {
type: {id: 1, name: 'Bug'},
sheep: 10,
customField1: 'asdf1234',
emptyField: null
};
scope.schema = {
emptyField: null,
schema: {
"$load": () => $q.when(true),
"_type": "Schema",
"type": {
@ -136,6 +142,10 @@ describe('wpDisplayAttr directive', () => {
compile();
});
it('should register the observer for that field', () => {
expect(wpEditForm.onWorkPackageUpdated.calledWith('wp-display-attr-type')).to.be.true;
});
it('should contain the object title', () => {
var content = getInnermostSpan(element);

@ -97,7 +97,7 @@ export class WorkPackageDisplayAttributeController {
this.displayType = 'SelfLink';
this.displayLink = this.PathHelper.workPackagePath(this.workPackage.id);
}
else if (!this.schema[this.attribute]) {
else if (!this.workPackage.schema[this.attribute]) {
this.displayType = 'Text';
}
else {
@ -170,7 +170,6 @@ function wpDisplayAttrDirective() {
link: wpTdLink,
scope: {
schema: '=',
workPackage: '=',
attribute: '=',
label: '=',

Loading…
Cancel
Save