mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-05 22:26:07 +00:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user