aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorPaul Meskers2013-06-09 16:20:40 -0400
committerIgor Minar2013-07-24 12:06:19 -0700
commit408e868237d80f9332f2c540f91b2809d9938fbc (patch)
tree6d658bd280385f2df0bcfc37d9038c1b08f9c9f2 /test
parent97abb124738e0ca5d00d807d65c482f7890feadd (diff)
downloadangular.js-408e868237d80f9332f2c540f91b2809d9938fbc.tar.bz2
fix(numberFilter): always convert scientific notation to decimal
Previously, the number filter would format small and large numbers as scientific notation. It now uses toFixed() to ensure that all requested digits are shown.
Diffstat (limited to 'test')
-rw-r--r--test/ng/filter/filtersSpec.js21
1 files changed, 18 insertions, 3 deletions
diff --git a/test/ng/filter/filtersSpec.js b/test/ng/filter/filtersSpec.js
index d60db9de..abe180df 100644
--- a/test/ng/filter/filtersSpec.js
+++ b/test/ng/filter/filtersSpec.js
@@ -145,9 +145,24 @@ describe('filters', function() {
expect(number(1234.567, 2)).toEqual("1,234.57");
});
- it('should filter exponential numbers', function() {
- expect(number(1e50, 0)).toEqual('1e+50');
- expect(number(-2e50, 2)).toEqual('-2e+50');
+ it('should filter exponentially large numbers', function() {
+ expect(number(1e50)).toEqual('1e+50');
+ expect(number(-2e100)).toEqual('-2e+100');
+ });
+
+ it('should ignore fraction sizes for large numbers', function() {
+ expect(number(1e50, 2)).toEqual('1e+50');
+ expect(number(-2e100, 5)).toEqual('-2e+100');
+ });
+
+ it('should filter exponentially small numbers', function() {
+ expect(number(1e-50, 0)).toEqual('0');
+ expect(number(1e-6, 6)).toEqual('0.000001');
+ expect(number(1e-7, 6)).toEqual('0.000000');
+
+ expect(number(-1e-50, 0)).toEqual('-0');
+ expect(number(-1e-6, 6)).toEqual('-0.000001');
+ expect(number(-1e-7, 6)).toEqual('-0.000000');
});
});