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

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

Loading…
Cancel
Save