FIX: allows to define label/title properties for display instead of name

Usage:

```
const content = [{foo: "FOO", bar: "BAR", value: 1, name: "foo-bar"}];

{{combo-box
  content=content
  value=value
  labelProperty="foo"
  titleProperty="bar"
}}
```
This commit is contained in:
Joffrey JAFFEUX
2020-05-28 08:30:31 +02:00
committed by GitHub
parent ecc8e559ec
commit 0854785175
6 changed files with 82 additions and 10 deletions
@@ -296,3 +296,45 @@ componentTest("focusAfterOnChange", {
);
}
});
componentTest("labelProperty", {
template: '{{single-select labelProperty="foo" value=value content=content}}',
beforeEach() {
this.setProperties({
content: [{ id: 1, name: "john", foo: "JACKSON" }],
value: 1
});
},
async test(assert) {
assert.equal(this.subject.header().label(), "JACKSON");
await this.subject.expand();
const row = this.subject.rowByValue(1);
assert.equal(row.label(), "JACKSON");
}
});
componentTest("titleProperty", {
template: '{{single-select titleProperty="foo" value=value content=content}}',
beforeEach() {
this.setProperties({
content: [{ id: 1, name: "john", foo: "JACKSON" }],
value: 1
});
},
async test(assert) {
assert.equal(this.subject.header().title(), "JACKSON");
await this.subject.expand();
const row = this.subject.rowByValue(1);
assert.equal(row.title(), "JACKSON");
}
});