Ensure value always shows

Even thought it's not valid (you can't save items with an empty name), it's disconcerting when the value suddenly disappears from view.
This commit is contained in:
David Cook
2024-03-27 17:18:05 +11:00
parent 99121943a7
commit b9b2c876cc
2 changed files with 9 additions and 0 deletions

View File

@@ -13,7 +13,10 @@ export default class OptionValueNamer {
const name_fields = [];
if (value && unit) {
name_fields.push(`${value}${separator}${unit}`);
} else if (value) {
name_fields.push(value);
}
if (this.variant.unit_description) {
name_fields.push(this.variant.unit_description);
}

View File

@@ -18,6 +18,12 @@ describe("OptionValueNamer", () => {
namer = new OptionValueNamer(v);
});
it("when unit is blank (empty items name)", function() {
jest.spyOn(namer, "value_scaled").mockImplementation(() => true);
jest.spyOn(namer, "option_value_value_unit").mockImplementation(() => ["value", ""]);
expect(namer.name()).toBe("value");
});
it("when description is blank", function() {
v.unit_description = null;
jest.spyOn(namer, "value_scaled").mockImplementation(() => true);