diff options
| author | Di Peng | 2011-07-23 17:05:20 -0700 | 
|---|---|---|
| committer | Igor Minar | 2011-07-26 14:16:57 -0700 | 
| commit | 31b59efa961e8729a0153d7d6ea5e300d7db17f2 (patch) | |
| tree | 74088ab4040111710b7c55a1c6049801730fb654 /test | |
| parent | 17251372b1dedb42d27b01375125cee4f5edcce7 (diff) | |
| download | angular.js-31b59efa961e8729a0153d7d6ea5e300d7db17f2.tar.bz2 | |
feat(number/currency filter): format numbers and currency using pattern
both numbers and currency need to be formatted using a generic pattern
which can be replaced for a different pattern when angular is working in
a non en-US locale
for now only en-US locale is supported, but that will change in the
future
Diffstat (limited to 'test')
| -rw-r--r-- | test/FiltersSpec.js | 25 | 
1 files changed, 16 insertions, 9 deletions
diff --git a/test/FiltersSpec.js b/test/FiltersSpec.js index 6bcdb511..f87d0317 100644 --- a/test/FiltersSpec.js +++ b/test/FiltersSpec.js @@ -28,16 +28,16 @@ describe('filter', function() {    });    describe('currency', function() { -    it('should do basic filter', function() { +    it('should do basic currency filtering', function() {        var html = jqLite('<span/>');        var context = {$element:html};        var currency = bind(context, filter.currency);        expect(currency(0)).toEqual('$0.00');        expect(html.hasClass('ng-format-negative')).toBeFalsy(); -      expect(currency(-999)).toEqual('$-999.00'); +      expect(currency(-999)).toEqual('($999.00)');        expect(html.hasClass('ng-format-negative')).toBeTruthy(); -      expect(currency(1234.5678)).toEqual('$1,234.57'); +      expect(currency(1234.5678, "USD$")).toEqual('USD$1,234.57');        expect(html.hasClass('ng-format-negative')).toBeFalsy();      });    }); @@ -46,13 +46,14 @@ describe('filter', function() {      it('should do basic filter', function() {        var context = {jqElement:jqLite('<span/>')};        var number = bind(context, filter.number); -        expect(number(0, 0)).toEqual('0'); -      expect(number(0)).toEqual('0.00'); -      expect(number(-999)).toEqual('-999.00'); -      expect(number(1234.5678)).toEqual('1,234.57'); +      expect(number(-999)).toEqual('-999'); +      expect(number(123)).toEqual('123'); +      expect(number(1234567)).toEqual('1,234,567'); +      expect(number(1234)).toEqual('1,234'); +      expect(number(1234.5678)).toEqual('1,234.568');        expect(number(Number.NaN)).toEqual(''); -      expect(number("1234.5678")).toEqual('1,234.57'); +      expect(number("1234.5678")).toEqual('1,234.568');        expect(number(1/0)).toEqual("");        expect(number(1,        2)).toEqual("1.00");        expect(number(.1,       2)).toEqual("0.10"); @@ -64,11 +65,17 @@ describe('filter', function() {        expect(number(.99,      2)).toEqual("0.99");        expect(number(.999,     3)).toEqual("0.999");        expect(number(.9999,    3)).toEqual("1.000"); -      expect(number(1e50,     0)).toEqual("1e+50");        expect(number(1234.567, 0)).toEqual("1,235");        expect(number(1234.567, 1)).toEqual("1,234.6");        expect(number(1234.567, 2)).toEqual("1,234.57");      }); + +    it('should filter exponential numbers', function() { +      var context = {jqElement:jqLite('<span/>')}; +      var number = bind(context, filter.number); +      expect(number(1e50, 0)).toEqual('1e+50'); +      expect(number(-2e50, 2)).toEqual('-2e+50'); +    });    });    describe('json', function () {  | 
