From b24d5a1efca786fde40dd639a64904dedddc1218 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sat, 25 Apr 2015 21:30:11 -0600 Subject: [PATCH] Move CRM.sigfig into CRM.utils --- js/Common.js | 2 +- tests/karma/unit/sigfigSpec.js | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/js/Common.js b/js/Common.js index 6591172036..2044bafc76 100644 --- a/js/Common.js +++ b/js/Common.js @@ -1382,7 +1382,7 @@ CRM.strings = CRM.strings || {}; }; // Round while preserving sigfigs - CRM.sigfig = function(n, digits) { + CRM.utils.sigfig = function(n, digits) { var len = ("" + n).length; var scale = Math.pow(10.0, len-digits); return Math.round(n / scale) * scale; diff --git a/tests/karma/unit/sigfigSpec.js b/tests/karma/unit/sigfigSpec.js index 9b593b3d63..088dd2370a 100644 --- a/tests/karma/unit/sigfigSpec.js +++ b/tests/karma/unit/sigfigSpec.js @@ -1,14 +1,14 @@ 'use strict'; -describe('CRM.sigfig', function() { +describe('CRM.utils.sigfig', function() { it('should round while preserving significant digits', function(){ - expect(CRM.sigfig(9, 1)).toBe(9); - expect(CRM.sigfig(172, 1)).toBe(200); - expect(CRM.sigfig(172, 2)).toBe(170); - expect(CRM.sigfig(176, 2)).toBe(180); - expect(CRM.sigfig(1492, 1)).toBe(1000); - expect(CRM.sigfig(1492, 2)).toBe(1500); - expect(CRM.sigfig(1492, 3)).toBe(1490); - expect(CRM.sigfig(10943, 3)).toBe(10900); + expect(CRM.utils.sigfig(9, 1)).toBe(9); + expect(CRM.utils.sigfig(172, 1)).toBe(200); + expect(CRM.utils.sigfig(172, 2)).toBe(170); + expect(CRM.utils.sigfig(176, 2)).toBe(180); + expect(CRM.utils.sigfig(1492, 1)).toBe(1000); + expect(CRM.utils.sigfig(1492, 2)).toBe(1500); + expect(CRM.utils.sigfig(1492, 3)).toBe(1490); + expect(CRM.utils.sigfig(10943, 3)).toBe(10900); }); }); -- 2.25.1