aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorVojta Jina2011-09-07 09:17:10 +0200
committerVojta Jina2011-09-08 17:59:45 +0200
commit4b1913c5ecac75e60e7a0de831100b6961d5d294 (patch)
tree724f37e320ce36bf16e04adbd288e2ae327f18a6 /test
parent06534413d3a33193853c39d0f9081709aac3908f (diff)
downloadangular.js-4b1913c5ecac75e60e7a0de831100b6961d5d294.tar.bz2
fix(filter.currency): Return empty string for non-numbers
Diffstat (limited to 'test')
-rw-r--r--test/FiltersSpec.js23
1 files changed, 18 insertions, 5 deletions
diff --git a/test/FiltersSpec.js b/test/FiltersSpec.js
index 2673b36e..83d8aac0 100644
--- a/test/FiltersSpec.js
+++ b/test/FiltersSpec.js
@@ -83,20 +83,33 @@ describe('filter', function() {
});
describe('currency', function() {
- it('should do basic currency filtering', function() {
- var html = jqLite('<span/>');
- var context = createScope();
+ var currency, html, context;
+
+ beforeEach(function() {
+ html = jqLite('<span></span>');
+ context = createScope();
context.$element = html;
- var currency = bind(context, filter.currency);
+ currency = bind(context, filter.currency);
+ });
+ afterEach(function() {
+ dealoc(context);
+ });
+
+ it('should do basic currency filtering', function() {
expect(currency(0)).toEqual('$0.00');
expect(html.hasClass('ng-format-negative')).toBeFalsy();
expect(currency(-999)).toEqual('($999.00)');
expect(html.hasClass('ng-format-negative')).toBeTruthy();
expect(currency(1234.5678, "USD$")).toEqual('USD$1,234.57');
expect(html.hasClass('ng-format-negative')).toBeFalsy();
+ });
- dealoc(context);
+ it('should return empty string for non-numbers', function() {
+ expect(currency()).toBe('');
+ expect(html.hasClass('ng-format-negative')).toBeFalsy();
+ expect(currency('abc')).toBe('');
+ expect(html.hasClass('ng-format-negative')).toBeFalsy();
});
});