From 99121943a7fc23277374f05c3da853b77415ff68 Mon Sep 17 00:00:00 2001 From: David Cook Date: Wed, 27 Mar 2024 20:13:59 +1100 Subject: [PATCH] Fix bug I missed a bit in a refactor, and it wasn't covered by the spec. --- app/webpacker/js/services/variant_unit_manager.js | 3 ++- spec/javascripts/services/variant_unit_manager_test.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/webpacker/js/services/variant_unit_manager.js b/app/webpacker/js/services/variant_unit_manager.js index 13f963bdb6..1711025fcd 100644 --- a/app/webpacker/js/services/variant_unit_manager.js +++ b/app/webpacker/js/services/variant_unit_manager.js @@ -21,7 +21,8 @@ export default class VariantUnitManager { .filter(([scale, scaleInfo]) => { return scaleInfo['system'] == scaleSystem; }) - .map(([scale, _]) => parseFloat(scale)); + .map(([scale, _]) => parseFloat(scale)) + .sort(); } // private diff --git a/spec/javascripts/services/variant_unit_manager_test.js b/spec/javascripts/services/variant_unit_manager_test.js index 3e1777b30b..cfd9c6f376 100644 --- a/spec/javascripts/services/variant_unit_manager_test.js +++ b/spec/javascripts/services/variant_unit_manager_test.js @@ -40,6 +40,7 @@ describe("VariantUnitManager", function() { it("returns a sorted set of compatible scales based on the scale and unit type provided", function() { expect(subject.compatibleUnitScales(1, "weight")).toEqual([1.0, 1000.0, 1000000.0]); expect(subject.compatibleUnitScales(453.6, "weight")).toEqual([28.35, 453.6]); + expect(subject.compatibleUnitScales(0.001, "volume")).toEqual([0.001, 1.0, 1000.0]); }); }); });