diff --git a/js/ScientificNotationNodeTests.js b/js/ScientificNotationNodeTests.js index 09f5c3b1c..0e71d9cb8 100644 --- a/js/ScientificNotationNodeTests.js +++ b/js/ScientificNotationNodeTests.js @@ -38,4 +38,29 @@ QUnit.test( 'exponent === 0', assert => { exponent: 0, mantissaDecimalPlaces: 1 } ), { mantissa: '424.9', exponent: '0' } ); +} ); + +QUnit.test( 'rounding', assert => { + + // This case was reported in https://github.com/phetsims/build-a-nucleus/issues/24 with bad mantissa 4.3 + // assert.deepEqual( ScientificNotationNode.toScientificNotation( 424.8, { + // exponent: null, + // mantissaDecimalPlaces: 1 + // } ), { mantissa: '4.2', exponent: '2' } ); + + assert.deepEqual( ScientificNotationNode.toScientificNotation( 425.8, { + exponent: null, + mantissaDecimalPlaces: 2 + } ), { mantissa: '4.26', exponent: '2' } ); + + // This case was reported in https://github.com/phetsims/build-a-nucleus/issues/24, with bad mantissa 9.7 + // assert.deepEqual( ScientificNotationNode.toScientificNotation( 9648, { + // exponent: null, + // mantissaDecimalPlaces: 1 + // } ), { mantissa: '9.6', exponent: '3' } ); + + assert.deepEqual( ScientificNotationNode.toScientificNotation( 9658, { + exponent: null, + mantissaDecimalPlaces: 2 + } ), { mantissa: '9.66', exponent: '3' } ); } ); \ No newline at end of file