forked from eclipsesource/jsonforms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fir for issue eclipsesource#197: Alignment of labels within horizonta…
…l layouts * Fix for eclipsesource#197: handle control alignment semantics when dealing with configurable label alignments * Fix for eclipsesource#197: Fix test case
- Loading branch information
1 parent
e04ef78
commit 4e66ed5
Showing
6 changed files
with
144 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
components/renderers/layouts/horizontal/horizontal-renderer.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/// <reference path="../../../references.ts"/> | ||
|
||
describe('HorizontalLayout', () => { | ||
|
||
// load all necessary modules and templates | ||
beforeEach(module('jsonforms.form')); | ||
beforeEach(module('jsonforms.renderers.layouts.horizontal')); | ||
beforeEach(module('jsonforms.renderers.controls.string')); | ||
|
||
beforeEach(module('components/form/form.html')); | ||
beforeEach(module('components/renderers/layouts/layout.html')); | ||
beforeEach(module('components/renderers/controls/control.html')); | ||
|
||
it("should take into account if some labels are hidden", inject(($rootScope, $compile) => { | ||
let scope = $rootScope.$new(); | ||
scope.schema = { | ||
"properties": { | ||
"foo": { "type": "string" }, | ||
"bar": { "type": "string" } | ||
} | ||
}; | ||
scope.uiSchema = { | ||
"type": "HorizontalLayout", | ||
"elements": [ | ||
{ | ||
"type": "Control", | ||
"label": true, | ||
"scope": { "$ref": "#/properties/foo" } | ||
}, | ||
{ | ||
"type": "Control", | ||
"label": false, | ||
"scope": { "$ref": "#/properties/bar" } | ||
} | ||
] | ||
}; | ||
|
||
scope.data = { "foo": "quux", "bar": "baz" }; | ||
let el = $compile('<jsonforms schema="schema" ui-schema="uiSchema" data="data"/>')(scope); | ||
scope.$digest(); | ||
let labelElements = el.find('label'); | ||
expect(labelElements).toBeDefined(); | ||
// one label is empty | ||
expect(labelElements.length).toEqual(2); | ||
expect(angular.element(labelElements[0]).text()).toEqual("Foo"); | ||
expect(angular.element(labelElements[1]).text()).toEqual(""); | ||
})); | ||
|
||
it("should take into account if all labels are hidden", inject(($rootScope, $compile) => { | ||
let scope = $rootScope.$new(); | ||
scope.schema = { | ||
"properties": { | ||
"foo": { "type": "string" }, | ||
"bar": { "type": "string" } | ||
} | ||
}; | ||
scope.uiSchema = { | ||
"type": "HorizontalLayout", | ||
"elements": [ | ||
{ | ||
"type": "Control", | ||
"label": { | ||
show: false | ||
}, | ||
"scope": { "$ref": "#/properties/foo" } | ||
}, | ||
{ | ||
"type": "Control", | ||
"label": { | ||
show: false | ||
}, | ||
"scope": { "$ref": "#/properties/bar" } | ||
} | ||
] | ||
}; | ||
|
||
scope.data = { "foo": "quux", "bar": "baz" }; | ||
let el = $compile('<jsonforms schema="schema" ui-schema="uiSchema" data="data"/>')(scope); | ||
scope.$digest(); | ||
let labelElements = el.find('label'); | ||
expect(labelElements.length).toBe(0); | ||
})); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters